Having trouble getting map to center of Pacific - Always goes to Atlantic

96 views
Skip to first unread message

Flash Gordon

unread,
Feb 15, 2011, 5:52:54 PM2/15/11
to google-map...@googlegroups.com
Hello,

I am having trouble with one of my maps. I run a site on Joomla, and I have maps that pull in the last 150 articles for that "region" and display where they are located in a Google Map. I have a region for each place in the world (North America, South America, etc.). All of the maps work perfectly, except for my map "Oceania". Instead of centering over the display of markers, the map always centers over the Atlantic Ocean where there are no markers. You can move the map and see that all of the markers are displayed, but for some reason the map won't start there. The coding for how the map works begins with 1.000000, 1.000000 for the general center, and then takes the last 150 articles' lat and lon to create the map. What I can't figure out is why does it ONLY not work for the "Oceania" map? Any ideas, help?

Here is the URL to the bad map: http://indigenouspeoplesissues.com/index.php?option=com_content&view=category&id=58&Itemid=80

Here is the URL to another map that works: http://indigenouspeoplesissues.com/index.php?option=com_content&view=category&id=54&Itemid=76

Thanks.

Esa

unread,
Feb 15, 2011, 6:05:34 PM2/15/11
to Google Maps JavaScript API v3
There is a separate group for Maps API version 2.
http://groups.google.com/group/google-maps-api

Rossko

unread,
Feb 15, 2011, 8:17:11 PM2/15/11
to Google Maps JavaScript API v3
> except for my map "Oceania". Instead of centering over the display of
> markers, the map always centers over the Atlantic Ocean

I'll hazard a guess which is just as relevant to v3 API.
If you have markers in the Pacific at longitudes, say, -160 and +160,
the centre of the bounds object including those two will be near zero
(in the Atlantic)

Chris Broadfoot

unread,
Feb 16, 2011, 1:14:57 AM2/16/11
to google-map...@googlegroups.com, Flash Gordon
Definitely post this to the v2 group. I'll have a stab anyway. There's a lot of code so I can't really figure it out, but I'd guess the problem is here:

        var sw = autoBounds.getSouthWest();
        var ne = autoBounds.getNorthEast();
        center = new GLatLng(
          ( sw.lat() + ne.lat() ) / 2,
          ( sw.lng() + ne.lng() ) / 2 );
Should use getCenter instead of averaging the lat and lng values.

Chris

Flash Gordon

unread,
Feb 16, 2011, 9:53:10 AM2/16/11
to Google Maps JavaScript API v3
Thank you Chris, that is an idea I will have to explore. I just wish I
knew more coding to fix the problem, but what you say makes sense.

Flash Gordon

unread,
Feb 16, 2011, 9:53:52 AM2/16/11
to Google Maps JavaScript API v3
Thanks Rossko, I will have to see if there are any markers with those
longitudes.
Reply all
Reply to author
Forward
0 new messages