我想使標記與markerClusterer成簇,但我無法使用jQuery UI地圖獲取地圖實例。 JS在jQuery UI地圖中獲取地圖的實例
嘗試:
變種地圖= $( '#map_canvas提供')GMAP( '的GetMap');。 或 var map = $('map_canvas')。gmap('get','map');
之後: var markerCluster = new MarkerClusterer(map,allMarkers);
但有錯誤
謝謝
我想使標記與markerClusterer成簇,但我無法使用jQuery UI地圖獲取地圖實例。 JS在jQuery UI地圖中獲取地圖的實例
嘗試:
變種地圖= $( '#map_canvas提供')GMAP( '的GetMap');。 或 var map = $('map_canvas')。gmap('get','map');
之後: var markerCluster = new MarkerClusterer(map,allMarkers);
但有錯誤
謝謝
嘗試這個。沒有錯誤但沒有羣集...
$('#map_canvas').gmap({ 'callback': function() {
var self = this;
$.getJSON('Data/markers.json', function (data) {
$.each(data.markers, function (i, marker) {
self.addMarker({ 'position': new google.maps.LatLng(marker.latitude,marker.longitude)}).click(function() {
$.ajax({
type: "GET",
url: "/LocoMap/LocoMap/InfoMobilePartialView/",
data: { latitude: marker.latitude, longitude: marker.longitude},
success: function (data) {
$("#marker-info").remove();
$(document.body).append("<div id='marker-info' data-role ='page'> </div>");
var $contentDiv = $("#marker-info");
$contentDiv.html(data).trigger('create');
$.mobile.changePage("#marker-info", { changeHash: false, type: "get", transition: 'pop',rel:"external" });
},
error: function (errorData) { onError(errorData); }
});
});
});
});
self.set('MarkerClusterer', new MarkerClusterer(this.get('map'), this.get('markers')));
}});
$('#map_canvas').gmap({'zoom': 2, 'disableDefaultUI':true}).bind('init', function(evt, map) {
$.getJSON('Data/markers.json', function(data) {
$.each(data.markers, function(i, m)
$('#map_canvas').gmap('addMarker', { 'position': new google.maps.LatLng(m.latitude, m.longitude), 'bounds':true });
});
});
$('#map_canvas').gmap('set', 'MarkerClusterer', new MarkerClusterer(map,$(this).gmap('get', 'markers')));
});
with no errors and no clusters
it seems **$(this).gmap('get', 'markers')));** returns Array[0]
第二次嘗試是正確的,無法回答沒有更多細節 –
什麼錯誤?你的其他代碼是什麼樣的? – geocodezip