简体   繁体   中英

In google Maps API V3, How can I Prevent markers from repeating on x axis without using the limiting panning solution?

I've been looking all over for the answer to this and I know that there is a way because leaflet does it in their framework. The thing is I am already using the Google APi and cannot turn back everything to leaflet plus I don't want to use leaflet and I cannot limit the boundaries as this would present some very odd and clunky solution to my map app. Does anybody know at all how to disable world wrapping on x-axis for google maps api v3? Again, please don't say about limiting panning and and bounds and step up the zooming. I've already tried this and this is not what I want, plus it really did not work well. If leaflet can do it with one porperty of worldwrap: false, then how can the same thing be achieved in Googles own framework?

The only way I've managed to do this is very crude.

First set the marker(s) to draggabble. Which stops the marker repeating longitudinally.

Then add a drag start and drag end handler.

on drag start, save the markers position.

on drag end, set the markers position back to its original position.

crude but seems to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM