我显示了一个特定位置的地图,地图上固定了兴趣点。这已经完成......我要做的是添加以下功能:如果用户位于此地图的现有范围内,则显示用户当前位置放大 10 并放置这些引脚。如果用户不在地图范围内,只需显示带有兴趣点图钉的地图。
我已经包含了一部分代码,无论地图的现有边界如何,都将显示用户位置,或者只显示没有用户位置的边界。你会看到我一直在玩弄这些功能却一无所获。
GeoMarker = new GeolocationMarker();
GeoMarker.setCircleOptions({fillColor: '#808080',fillOpacity:0.0,strokeOpacity:0.0});
google.maps.event.addListenerOnce(GeoMarker, 'position_changed', function() {
map.setCenter(this.getPosition());
//map.fitBounds(this.getBounds()); //uncomment to show based on user location regardless of the exsisting bounds of the map
//map.fitBounds(bounds); //uncomment to show ALL the listing Markers within the bounds of the map and not location of the user
//if (map.getZoom() > 1) map.setZoom(13); //this zoom is based on user location
// map.setCenter(this.getPosition());
var listener = google.maps.event.addListener(map, "idle", function() {
google.maps.event.removeListener(listener);
});
});
google.maps.event.addListener(GeoMarker, 'geolocation_error', function(e) {
alert('There was an error obtaining your position. Message: ' + e.message);
});
GeoMarker.setMap(map);
}