I'm currently migrating from v2 to v3. The world should not be repeated longitudinally.
In v2 this could be archived with something like this:
var proj = new GMercatorProjection(30);
proj.tileCheckRange = function(a,b,c) {
var tileBounds = Math.pow(2,b);
if (a.y<0 || a.y >= tileBounds) {return false;}
if (a.x<0 || a.x >= tileBounds) {return false;}
return true;
};
proj.getWrapWidth = function(zoom) {
return 99999999999999;
};
G_NORMAL_MAP.getProjection = function() {return proj;};
But I have yet to find a solution for v3.
EDIT To clarify a bit: I'm not looking for a way to prevent panning (navigating sideways) but a way to prevent the map from repeating it self, esp. at low zoom-levels
Check out the two answers at How do I limit panning in Google maps API V3?. The technique outlined there should get you (depending on your use case) most of the way there or maybe all the way there.
Those answers do not show how to limit wrapping, but they do show how to limit panning. If you can take other measures to restrict what's in the initial viewport (say, if you have control over the size and can restrict the zoom levels and initial coordinates appropriately), then limiting panning can get you there.
The restriction
MapOption
property can help here.
new google.maps.Map(
container,
{
restriction:
{
latLngBounds: {north: 85, south: -85, west: -179.5, east: 179.5},
strictBounds: true
}
});
This will also take care of the "padding" that is usually displayed beyond the north/east bounds and make the map "end" where the map tiles end.
You can fiddle with the numbers a bit to account for a bit more (or a bit more accurate) area, but I think it should be enough for most cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With