-1
如果你看看这个页面:https://banting.co.za/find-a-coach/缩放级别 - 谷歌地图,国家
你会看到世界地图几乎复制本身,它是一个插件,但是 有一些简单的我失踪使世界地图适合没有它重复?
/** * 所有位置映射脚本 */ 的jQuery(函数($){
$(document).ready(function(){
loadmap();
});
function loadmap()
{
var locations = wpsl_locator_all.locations;
var mapstyles = wpsl_locator.mapstyles;
var mappin = (wpsl_locator.mappin) ? wpsl_locator.mappin : '';
var bounds = new google.maps.LatLngBounds();
var mapOptions = {
mapTypeId: 'roadmap',
mapTypeControl: false,
zoom: 8,
styles: mapstyles,
panControl : false
}
if (wpsl_locator.custom_map_options === '1') mapOptions = wpsl_locator.map_options;
var infoWindow = new google.maps.InfoWindow(), marker, i;
var map = new google.maps.Map(document.getElementById('alllocationsmap'), mapOptions);
// Loop through array of markers & place each one on the map
for(i = 0; i < locations.length; i++) {
var position = new google.maps.LatLng(locations[i].latitude, locations[i].longitude);
bounds.extend(position);
var marker = new google.maps.Marker({
position: position,
map: map,
title: locations[i].title,
icon: mappin
});
// Info window for each marker
google.maps.event.addListener(marker, 'click', (function(marker, i){
return function() {
infoWindow.setContent(locations[i].infowindow);
infoWindow.open(map, marker);
wpsl_all_locations_marker_clicked(marker, infoWindow)
}
})(marker, i));
// Center the Map
map.fitBounds(bounds);
var listener = google.maps.event.addListener(map, "idle", function() {
if (locations.length < 2) {
map.setZoom(13);
}
google.maps.event.removeListener(listener);
});
}
// Fit the map bounds to all the pins
var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) {
google.maps.event.removeListener(boundsListener);
});
wpsl_all_locations_rendered(map);
} // loadmap()
});
我建议你看一下这个问题:https://stackoverflow.com/questions/20498210/display-world-map-with不重复 – user8284082