Error Calling MarkerManager's addMarker Method ("this.getProjection() undefined")

625 views
Skip to first unread message

bkjanes

unread,
May 26, 2010, 10:13:52 AM5/26/10
to Google Maps JavaScript API v3
I'm not sure if this is the right forum, but I'm having trouble
porting some API v2 code to v3 using the Google Maps Utility Library's
markermanager.js library. After the script calls the addMarker method,
a JavaScript error is reported in line 958 of markermanager.js stating
"this.getProjection() is undefined".

Both of these pages are prototypes and are still under development,
but I've posted them on a personal web site:

The API v2 version is at http://dashboard.nfshost.com/traffic-map.htm

The API v3 version that's getting the error is at
http://dashboard.nfshost.com/traffic-v3.htm

I'm not sure if this error due to something that I've converted
incorrectly, or if it's an error in the markermanager.js code, so I'm
humbly posting it for some help and advice.

Thank you in advance for your time.

Keith

Miguel Angel Vilela

unread,
May 26, 2010, 10:59:42 AM5/26/10
to google-map...@googlegroups.com

There is a different version of markermanager.js for the V3 API, here:


getProjection is a valid method for the Map class in V3, but the library also uses getCurrentMapType which is not.
If you look at the link above, it doesn't even use getProjection, so my guess is that you are using the old version of markermanager.js which only works with the V2 API.

Cheers,
Miguel


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
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.

bkjanes

unread,
May 26, 2010, 11:47:13 AM5/26/10
to Google Maps JavaScript API v3
Thanks Miguel.

Is there another URL that I can use to reference "markermanager.js" in
the <script> tag, or do I need to download the "markermanager.js" file
to my server and reference it from there? Which is the recommended
best practice?

Keith

On May 26, 9:59 am, Miguel Angel Vilela <mig...@google.com> wrote:
> There is a different version of markermanager.js for the V3 API, here:
>

> http://code.google.com/p/google-maps-utility-library-v3/source/browse...<http://code.google.com/p/google-maps-utility-library-v3/source/browse...>


>
> getProjection is a valid method for the Map class in V3, but the library
> also uses getCurrentMapType which is not.
> If you look at the link above, it doesn't even use getProjection, so my
> guess is that you are using the old version of markermanager.js which only
> works with the V2 API.
>
> Cheers,
> Miguel
>
>
>
> On Wed, May 26, 2010 at 16:13, bkjanes <bkja...@gmail.com> wrote:
> > I'm not sure if this is the right forum, but I'm having trouble
> > porting some API v2 code to v3 using the Google Maps Utility Library's
> > markermanager.js library. After the script calls the addMarker method,
> > a JavaScript error is reported in line 958 of markermanager.js stating
> > "this.getProjection() is undefined".
>
> > Both of these pages are prototypes and are still under development,
> > but I've posted them on a personal web site:
>

> > The API v2 version is athttp://dashboard.nfshost.com/traffic-map.htm


>
> > The API v3 version that's getting the error is at
> >http://dashboard.nfshost.com/traffic-v3.htm
>
> > I'm not sure if this error due to something that I've converted
> > incorrectly, or if it's an error in the markermanager.js code, so I'm
> > humbly posting it for some help and advice.
>
> > Thank you in advance for your time.
>
> > Keith
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Maps JavaScript API v3" group.
> > 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<google-maps-js-api-v3%2B­unsub...@googlegroups.com>


> > .
> > For more options, visit this group at

> >http://groups.google.com/group/google-maps-js-api-v3?hl=en.- Hide quoted text -
>
> - Show quoted text -

Miguel Angel Vilela

unread,
May 26, 2010, 12:29:15 PM5/26/10
to google-map...@googlegroups.com

Well, since you don't have control over whether, when or where the markermanager.js file will be moved or changed, it'd be safer to download it and serve it from your own server. On the other hand, that means that if the file is updated (new features or bug fixes) you need to download it again.

Cheers,
Miguel

To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

bkjanes

unread,
May 30, 2010, 5:32:01 PM5/30/10
to Google Maps JavaScript API v3
After downloading the current version of the "markermanager.js" script
file that Miguel recommended, and changing my web page to point to the
local copy, I get a different error. This time it's pointing to line
73 of the "markermanager.js" script file, which is a "get_zoom()"
method of the map object. Version 3 of the the Google Maps API doesn't
have a "get_zoom()" method spelled as such, but instead, has a
"getZoom()" method.

Is this really the most current version of MarkerManager? Is there
something else that I'm missing?

Again, my faulty map is at http://dashboard.nfshost.com/traffic-v3.htm

Thanks.
Keith

William

unread,
May 30, 2010, 9:14:14 PM5/30/10
to Google Maps JavaScript API v3
On May 31, 7:32 am, bkjanes <bkja...@gmail.com> wrote:
>
> Is there something else that I'm missing?
>

yeah there is a race condition in your code, because the MarkerManager
isn't ready immediately after construction.

Internally the MarkerManager generates a 'ready' event to signify the
projection() is available, and then it initializes() and finally
raises a 'loaded' event.

So the race condition error occurs when the marker XML is downloaded
before the MarkerManager is ready.

you will need to change your code like this:

google.maps.event.addListener(mgr, 'loaded', function() {
downloadUrl("ALDOTTrafficMarkers.xml", function(data) {
});
});

...

this page has some examples:
http://google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/docs/examples.html
Reply all
Reply to author
Forward
0 new messages