Error adding marker to the marker manager

47 views
Skip to first unread message

Nathan Raley

unread,
Jun 9, 2010, 5:37:31 PM6/9/10
to Google Maps JavaScript API v3
Okay, I am having a bit of a problem moving from v2 to v3.  I've narrowed down the error to adding a marker to the marker manager.

I am storing markers that are using coordinates from user values into an array StartFinishMarkers[].

I create my MarkerManager via:
ZoneStartFinishMM = new MarkerManager(map);

I create the Markers via:
StartMarkerOptions = { "icon": StartPoint, "clickable": true, "draggable": true, "title": Number };
FinishMarkerOptions = { "icon": FinishPoint, "clickable": true, "draggable": true, "title": Number };
var StartMarker = new google.maps.Marker(point1, StartMarkerOptions);
var FinishMarker = new google.maps.Marker(point2, FinishMarkerOptions);

Now I have my Marker Manager and Markers created, I used try catches to ensure there were no errors creating either the marker or the manager.

Now I use the following:
ZoneStartFinishMM.addMarker(ZoneStartFinishMarkers[idStart], 0);
ZoneStartFinishMM.addMarker(ZoneStartFinishMarkers[idFinish], 0);

And it is tossing an error when trying to add the Markers this way.

Any ideas what's going on b/c I am completely stumped here.

Thanks,
Nathan

William

unread,
Jun 9, 2010, 5:58:38 PM6/9/10
to Google Maps JavaScript API v3
On Jun 10, 7:37 am, Nathan Raley <nlrale...@gmail.com> wrote:
> And it is tossing an error when trying to add the Markers this way.
>

What kind of error is being thrown?

have a look at this page which shows how to use the V3 MarkerManager:

http://google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/docs/examples.html

because almost everything in the V3 api is asynchronous, the marker
manager isn't ready until it notifies listeners with a "loaded"
event.

Here's a snippet from the examples page:

function setupWeatherMarkers() {

mgr = new MarkerManager(map);

google.maps.event.addListener(mgr, 'loaded', function() {
mgr.addMarkers(getWeatherMarkers(20), 3);
mgr.addMarkers(getWeatherMarkers(200), 6);
mgr.addMarkers(getWeatherMarkers(1000), 8);
mgr.refresh();
});

}

...

Nathan Raley

unread,
Jun 10, 2010, 9:39:25 AM6/10/10
to google-map...@googlegroups.com
I'm not getting a javascript error per say, my try catch for adding the markers to the marker manager is kicking an error and failing and the markers never show up.

How long does it take for the MM to initialize so I can use it?  Before it was almost instantaneous but now it seems as if it is taking forever.  My function in the c++ that calls the add markers function is getting called several times.

Is there a way to make sure its loaded before I continue on?

Nathan


--
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.


Nathan Raley

unread,
Jun 10, 2010, 10:28:11 AM6/10/10
to google-map...@googlegroups.com
I figured out what it was.

I was creating my marker with new google.maps.Marker(point1, MarkerOptions).

My point1 was a LatLng point in google maps.

In the version 3 API, you have to set the point of the Marker by doing position: LatLng and not how it was previously defined in v2 of the API.

Hope that helps someone else out there that may be having a similar issue.

Thanks for the help,
Nathan
Reply all
Reply to author
Forward
0 new messages