1
我是新的谷歌地圖,我添加ng-map但我有相同的問題官方plunker代碼plunker,標記不出現。 這是我的Angularjs代碼:Angularjs和谷歌地圖標記集羣
//Google maps
var app = angular.module('myApp',['ngMap', 'ngAnimate', 'ui.bootstrap', 'ui.select']);
app.controller('mapController', ['$scope','$http', 'NgMap', function($scope, $http, NgMap) {
NgMap.getMap().then(function(map) {
//Get all buildings for maps
$http({
method: 'GET',
url: '/booking/building/1',
}).then(function successCallback(response) {
if (typeof response.data.success == 'undefined'){
window.location.href = "/500";
}else if (response.data.success==true){
for (var i=0; i < response.data.result.length;i++){
var latLng = new google.maps.LatLng(response.data.result[i].latitude, response.data.result[i].longitude);
vm.dynMarkers.push(new google.maps.Marker({position:latLng, title:response.data.result[i].name}));
}
}else if (response.data.success==false)
notifyMessage(response.data.result, 'error');
}, function errorCallback(response) {
window.location.href = "/500";
});
vm.markerClusterer = new MarkerClusterer(map, vm.dynMarkers, {});
});
});
在這種情況下,我只有1個城市,但在未來我可能有座標的樂透。 在HTML中我有此腳本約NG-地圖:
<!-- Maps -->
<script th:src="@{/static/assets/plugins/angular-maps/ng-map.min.js}"
type="text/javascript"></script>
<script
src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/testapp/scripts/markerclusterer.js"></script>
<script>
MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_
= 'https://raw.githubusercontent.com/googlemaps/js-marker-clusterer/gh-pages/images/m1.png'; //changed image path
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=key">
</script>
我tryed刪除
<script>MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH = 'https://raw.githubusercontent.com/googlemaps/js-marker-clusterer/gh-pages/images/m1.png'; //changed image path
</script>
但結果還是一樣。我想只用地圖CDN鏈接。
你可以發佈你的應用程序的代碼的其餘部分?它看起來非常酷! – Zypps987