MarkerManager: Event Listener

89 views
Skip to first unread message

Dark Con

unread,
Oct 26, 2010, 1:49:25 PM10/26/10
to google-maps-uti...@googlegroups.com
I'm setting up my first project and have run into a small problem. I've tried to follow the examples provided with MarkerManager but the "loaded" event listener that I attach to the MarkerManager variable never fires. I've broken my code into functions attempting to follow the same style as the examples. When the page loads the first two log messages fire but nothing inside the addListener block is fired. Any help or insight is appreciated, code follows:

$(document).ready(function(){
// MarkerManager testing
var map;
var mgr;
console.log("Calling load");
load();
});

function load() {
map = new google.maps.Map(document.getElementById("gameMap"));
mgr = new MarkerManager(map);
console.log("Variables set");
google.maps.event.addListener(mgr, "loaded", function() {
console.log("Map ready");
setPoints();
google.maps.event.addListener(map, "zoom_changed", function() {
updateStatus(mgr.getMarkerCount(map.getZoom()));
});
});
}

If more code would help I can post the full code on pastebin. This is using the Google Maps v3 and MarkerManager 1.0 libraries.

Thanks in advance,
- dC

Björn Brala

unread,
Oct 27, 2010, 5:58:57 AM10/27/10
to google-maps-uti...@googlegroups.com
Can you please add an online exmple so i can debug it on a webpage?

2010/10/26 Dark Con <d4r...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "google-maps-utility-library-v3" group.
To post to this group, send email to google-maps-uti...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-utility-l...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-utility-library-v3?hl=en.




--
Bjorn Brala
----------------
www.GeoStart.nl/english/ - Google maps - Swis Webdesign
www.twitter.com/bbrala

Dark Con

unread,
Oct 28, 2010, 12:15:19 PM10/28/10
to google-maps-uti...@googlegroups.com
Hi Bjorn,

Thanks for the reply. I've posted a very simple version of the code here:

This has all my other page elements stripped out but still displays the same problem so this should be the simplest form. In the posted code the function  initMap() is called by the window.onload event but the google.maps.event.addListener I attach to the map object never fires. In the posted code I attached it to the "load" event of the map but I have also tried it with other events ("bounds_changed" and "zoom_changed", I think) with the same result. None of my listener events seem to trigger.

Thanks for your help.

Björn Brala

unread,
Nov 1, 2010, 4:51:45 AM11/1/10
to google-maps-uti...@googlegroups.com
Thank you for setting that up, i will have a look.

2010/10/28 Dark Con <d4r...@gmail.com>

Björn Brala

unread,
Nov 1, 2010, 5:16:53 AM11/1/10
to google-maps-uti...@googlegroups.com
I do see in the code you did not use any options on the map, why is there no center and no other options for the map onload? Without setting up the map events will not fire i think.

Also, just call the setupmarkers on load of the window, it is not neccesary to use an event for that, i changed the example to reflect this.

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markermanager/examples/weather_map.html




2010/11/1 Björn Brala <bbr...@gmail.com>

Dark Con

unread,
Nov 1, 2010, 12:25:06 PM11/1/10
to google-maps-uti...@googlegroups.com
Thanks for taking the time to help with this, Bjorn, that fixed the problem.

I thought the options array was an optional parameter and that leaving it out would have the map set to default parameters. In fact I needed to set all 3 map options (zoom, center and mapTypeId) before any events would fire. I initially tried it with only the zoom and center options set with the same result.

Thanks very much for your time.

Björn Brala

unread,
Nov 1, 2010, 6:40:47 PM11/1/10
to google-maps-uti...@googlegroups.com
No problem at all, have fun coding ;)

2010/11/1 Dark Con <d4r...@gmail.com>
Reply all
Reply to author
Forward
0 new messages