API V3 - is the fitBounds function depending of the order of markers ?

30 views
Skip to first unread message

wangba

unread,
Jun 15, 2011, 2:37:17 PM6/15/11
to google-map...@googlegroups.com
With Google maps V3. On this first test http://www.wangba.fr/test1.html  the map is setting up with 3 markers (see the page code):
          ["Port-au-Prince", 18.551426,-72.336845],
          ["Seoul", 37.586269,126.982498],
          ["Yaounde", 3.881587,11.516304]

And the map displays duplicated continents. Which is not a correct result.

The second test http://www.wangba.fr/test2.html the markers are the same but listed in a different order:

["Port-au-Prince", 18.551426,-72.336845], ["Yaounde", 3.881587,11.516304], ["Seoul", 37.586269,126.982498]

And here the result is correct (no duplicated continents). 

Is it a bug or a misunderstanding of the API  from my part ? Where are the explanations on how to manage these weird results ?

Thanks for your feedbacks

Ben Appleton

unread,
Jun 15, 2011, 6:19:26 PM6/15/11
to google-map...@googlegroups.com

This is working as intended. The smallest bounds containing Port-au-Prince and Seoul crosses the dateline, which is the difference you see.

Ben

> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/u02DzoDNZlYJ.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

Enoch Lau

unread,
Jun 16, 2011, 9:18:47 AM6/16/11
to google-map...@googlegroups.com
As Ben noted, the bounds are being computed correctly. But if the result still seems counterintuitive, change your map's width from 750px to 850px - this allows the computed bounds to fit at a zoom level that doesn't show multiple continents.
Reply all
Reply to author
Forward
0 new messages