我正在使用磁贴 id 在数据库中存储标记。
因此,当某个图块显示在地图上时,该图块包含的所有标记都是
也要求并显示。
所以我终于创建了一个无法正常工作的代码。它没有要求所有需要的
瓷砖。更准确地说,每次我移动地图时它只要求一个图块。
ServerFetchMapType.prototype.tileSize = new google.maps.Size(256,256);
ServerFetchMapType.prototype.maxZoom = 100;
ServerFetchMapType.prototype.name = "Server Tile #s";
ServerFetchMapType.prototype.alt = "Server Data Tile Map Type";
ServerFetchMapType.prototype.getTile = function(coord, zoom, ownerDocument){
if(zoom>10){
var tileId=this.getAddrLatLng(coord,zoom);
if(isTileAlreadyLoaded(tileId)){
return ;
}
ServerFetchedTiles[tileId] = true;
var url = "markerRequestPageJson.php?tileNumber=";
var json;
$.getJSON(url+tileId,function(json){
// this is where we can loop through the results in the json object
var _item;
var infoWindow = new google.maps.InfoWindow;
$.each(json, function(i,_item){
var point = new google.maps.LatLng(
parseFloat(_item.lat),
parseFloat(_item.lng));
var html = _item.id + "<br/>";
var marker = new google.maps.Marker({
map: map,
position: point
});
markerClusterer.addMarker(marker);
bindInfoWindow(marker, map, infoWindow, html);
});
});
}
return;
};
但最后我做了一些改变,它应该可以工作:
ServerFetchMapType.prototype.tileSize = new google.maps.Size(256,256);
ServerFetchMapType.prototype.maxZoom = 100;
ServerFetchMapType.prototype.name = "Server Tile #s";
ServerFetchMapType.prototype.alt = "Server Data Tile Map Type";
ServerFetchMapType.prototype.getTile = function(coord, zoom, ownerDocument){
if(zoom>10){
var tileId=this.getAddrLatLng(coord,zoom);
if(isTileAlreadyLoaded(tileId)){
return ;
}
ServerFetchedTiles[tileId] = true;
var div = ownerDocument.createElement('DIV');
var url = "markerRequestPageJson.php?tileNumber=";
var json;
$.getJSON(url+tileId,function(json){
// this is where we can loop through the results in the json object
var _item;
var infoWindow = new google.maps.InfoWindow;
$.each(json, function(i,_item){
var point = new google.maps.LatLng(
parseFloat(_item.lat),
parseFloat(_item.lng));
var html = _item.id + "<br/>";
var marker = new google.maps.Marker({
map: map,
position: point
});
markerClusterer.addMarker(marker);
bindInfoWindow(marker, map, infoWindow, html);
});
});
return div;
}
return;
};
我的问题:这是一个适当的解决方案吗?