Prevent horizontal cover wrappers in GMap v3

I am trying to create a map that does not wrap horizontally using the Google Maps API V3. Therefore, instead of repeating the card side by side again and again, I want to show it only once. I got this to work by providing a custom getTileUrl function for google.maps.ImageMapType

But when I add overlays (like markers or polygons), they still repeat horizontally. How can I stop the overlay from repeating horizontally?

Change Here is an image showing the problem: World-wrapping overlays

I was thinking about somehow changing the google.maps.Projection.fromLatLngToPoint () method, but for some reason it is almost inaccessible.

+4
source share
1 answer

Now I figured out how to do it. The solution was not related to a modified projection, but was instead raised by this question about restricting panning in Google Maps .

This is not as clean as we would like, but it works:

  • Instead of starting (showing the full map as a single map tile) at zoom level 0, start with a higher zoom level. In my case, I started at level 3. Thus, the "imaginary" whole world is larger, moving repeating overlays farther apart: great distance between repeating overlays

  • Limit the zoom level, so even have the lowest zoom level, there are no two duplicate overlays in the viewport. This is done by setting the minZoom parameter on the map to the desired level. viewport does not contain two repeating overlays

  • Restrict panning / dragging the map so that you cannot exit the desired area. See my answer to the limit pan question .

Thus, repeating overlays still exist, but you can never see them since you cannot reach them.

+2
source

All Articles