[Google Maps API v3] Dose MarkerManager works?

1,272 views
Skip to first unread message

TK

unread,
Apr 17, 2010, 3:13:02 AM4/17/10
to Google Maps JavaScript API v3

Dose MarkerManager script works? I read docment but seems not working.
http://google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/src/markermanager.js

I would like to see simple sample except bellow.
http://google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/examples/

Dose anyone use it please tell me your url that working?

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

TK

unread,
Apr 19, 2010, 4:55:49 AM4/19/10
to Google Maps JavaScript API v3

Have to use addMarkers() method not createMarker() use for
MarkerManager?

Cosmin Pitu

unread,
Apr 19, 2010, 1:50:43 AM4/19/10
to Google Maps JavaScript API v3
Hi,

Yes, MarkerManager works, just be sure to wrap your logic (calls to
methods such as addMarkers(..) and refresh(..) ) into a listener for
the 'loaded' event, such as :

var mgr = new MarkerManager(map);
google.maps.event.addListener(mgr, 'loaded', function()
{
// Stuff like addMarkers(), refresh() goes here
});

This took me a bit too, hadn't noticed that you have to bind it this
way - otherwise, it isn't properly initialized.
Message has been deleted

TK

unread,
Apr 19, 2010, 8:10:14 PM4/19/10
to Google Maps JavaScript API v3

Hi Cosmin Pitu,

Do you know how shoul I do? I'm a beginer of Javascripts.

Here is the url:
http://www.shift.jp.org/ja/map/


Code:

<script type="text/javascript" src="http://google-maps-utility-library-
v3.googlecode.com/svn/tags/markermanager/1.0/src/markermanager.js"></
script>

<script type="text/javascript">
var infowindow;
var map;

function initialize() {
var myLatlng = new google.maps.LatLng(35.689506, 139.691701);
var myOptions = {
zoom: 2,
center: myLatlng,
mapTypeControl: false,
navigationControl: true,
navigationControlOptions: {style:
google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
}

map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
mgr = new MarkerManager(map);

downloadUrl("http://www.shift.jp.org/ja/map/tokyodata.xml",
function(data) {
var markers =
data.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var latlng = new
google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(markers[i].getAttribute("name"),
latlng);
}
});
}

function createMarker(name, latlng) {
var marker = new google.maps.Marker({position: latlng, map: map,
title: name});
google.maps.event.addListener(marker, "click", function() {
if (infowindow) infowindow.close();
infowindow = new google.maps.InfoWindow({content: name});
infowindow.open(map, marker);
});
return marker;
}

</script>
<body onload="initialize()">

Cosmin Pitu

unread,
Apr 21, 2010, 2:18:19 AM4/21/10
to Google Maps JavaScript API v3
Hi,

First off, insert this line after your downloadUrl call, within the
closure function(data) { :

var markersForManager = []; // a addMarkers() Call expects an Array
of Markers, initialize it

Within your "for(var i = 0 ; i < markers.length; i++)", and after your
"var marker = createMarker(markers[i].getAttribute("name"), latlng);
", try adding this :

markersForManager.push(marker); // Add the marker object to the
array

After your "for(var i = 0 ; i < markers.length; i++)", add this :

mgr.addMarkers(markersForManager, 1, 22); // 1 is minimum zoom, 22
is maximum zoom, read MarkerManager documentation for more info. You
can add more of these calls, for various zoom levels.
mgr.refresh(); // This should place your markers on the map

Finally, wrap all your logic with downloadUrl("...") and its closure
within an event (which is triggered after MarkerManager is ready to
go) :

google.maps.event.addListener(mgr, "loaded",
function()
{
// Your downloadUrl() logic goes here.
}
);

Hope it works !

TK

unread,
Apr 21, 2010, 12:32:44 PM4/21/10
to Google Maps JavaScript API v3

Hi,

You are very kind! I try it but dosen't work. I'm sure I make mistake.
I know I should try and try but I don't know why.
Would be great if could help a few.

The reverse code is here.
http://www.shift.jp.org/ja/map/

TK

unread,
Apr 21, 2010, 9:41:45 PM4/21/10
to Google Maps JavaScript API v3

Done it. But still error :(
http://www.shift.jp.org/ja/map/index.html

Where should I place "mgr.refresh();" ?



On Apr 22, 5:36 am, Björn Brala <bbr...@gmail.com> wrote:
> Look at the error :)
>
> missing ) after argument list
>
> }
>
> Did this correction in your code, remember to close your functions properly
> :) Using the right indenting really helps.
>
> google.maps.event.addListener(mgr, "loaded", function() {
> downloadUrl("http://www.shift.jp.org/ja/map/tokyodata.xml", function(data)
> {
> var markersForManager = [];
> var markers = data.documentElement.getElementsByTagName("marker");
> for (var i = 0; i < markers.length; i++) {
> var latlng = new
> google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
> parseFloat(markers[i].getAttribute("lng")));
> var marker = createMarker(markers[i].getAttribute("name"), latlng);
> markersForManager.push(marker);
> }
> mgr.addMarkers(markersForManager, 1, 22);
> });
>
> });
>
> 2010/4/21 TK <taketo.ogu...@gmail.com>
>
>
>
>
>
> > Hi,
>
> > You are very kind! I try it but dosen't work. I'm sure I make mistake.
> > I know I should try and try but I don't know why.
> > Would be great if could help a few.
>
> > The reverse code is here.
> >http://www.shift.jp.org/ja/map/
>
> > --
> > 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%2Bunsu...@googlegroups.com>
> > .

Björn Brala

unread,
Apr 22, 2010, 4:41:23 AM4/22/10
to google-map...@googlegroups.com
Count the curly brackets! :)

The initliaze function  is not closed.

2010/4/22 TK <taketo...@gmail.com>

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

TK

unread,
Apr 22, 2010, 4:59:41 AM4/22/10
to Google Maps JavaScript API v3

Closed! But nothing happen at
http://www.shift.jp.org/ja/map/index.html

Error: grid has no properties
File: http://google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/src/markermanager.js
Line: 533

What this mean?



On Apr 22, 5:41 pm, Björn Brala <bbr...@gmail.com> wrote:
> Count the curly brackets! :)
>
> The initliaze function is not closed.
>
> 2010/4/22 TK <taketo.ogu...@gmail.com>
> > <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3%252Buns...@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > > --
> > > Bjorn Brala
> > > ----------------www.GeoStart.nl/english/-Google maps - Swis
> > Webdesignwww.twitter.com/bbrala
>
> > > --
> > > 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

Cosmin Pitu

unread,
Apr 22, 2010, 2:33:42 AM4/22/10
to Google Maps JavaScript API v3
Hi again,

I think the problem is that you are closing the initialize() function
as if it were a closure (e.g. something like
"google.maps.event.addListener(foo, function() { });" , notice the
usage of "});" instead of regular "}"), try changing :

"mgr.addMarkers(markersForManager, 1, 22);
mgr.refresh();
});
}); "

into

"mgr.addMarkers(markersForManager, 1, 22);
mgr.refresh();
});
} " // function initialize() { } not function initialize() { }); -
there's no parenthesis to close

You might want to fix the indenting as Bjorn indicated.
The call to refresh is ok, it's after the "for(".

Hope this helps !

TK

unread,
Apr 22, 2010, 10:46:49 AM4/22/10
to Google Maps JavaScript API v3

Hi again,

Still have errors

error: missing ) after argument list
file: http://www.shift.jp.org/ja/map/index.html
line: 49
code: function createMarker(name, latlng) {

error: initialize is not defined
file: http://www.shift.jp.org/ja/map/index.html
line: 1

Sorry many ask.

Björn Brala

unread,
May 6, 2010, 10:01:26 AM5/6/10
to google-map...@googlegroups.com
I posted this to the wrong thread, oops.

I think i fixed it ;)

http://www.geostart.nl/test.html


2010/4/22 TK <taketo...@gmail.com>

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

TK

unread,
May 7, 2010, 8:02:51 AM5/7/10
to Google Maps JavaScript API v3

You're so kind. I've put the code on
http://www.shift.jp.org/ja/map/index.html

I though there is one marker when zoom out but seems there are all
markers.

Is this right function of MarkerManager?



On 5月6日, 午後11:01, Björn Brala <bbr...@gmail.com> wrote:
> I posted this to the wrong thread, oops.
>
> I think i fixed it ;)
>
> http://www.geostart.nl/test.html
>
> 2010/4/22 TK <taketo.ogu...@gmail.com>
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > --
> > 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%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> --
> Bjorn Brala
> ----------------www.GeoStart.nl/english/- Google maps - Swis Webdesignwww.twitter.com/bbrala
>

TK

unread,
May 7, 2010, 11:00:59 AM5/7/10
to Google Maps JavaScript API v3

I would like to do like this with API v3.
http://www.shift.jp.org/en/map/
This is v2 version without MarkerManager.

Can't I do it with API v3 with MarkerManager?


On May 7, 9:02 pm, TK <taketo.ogu...@gmail.com> wrote:
> You're so kind. I've put the code onhttp://www.shift.jp.org/ja/map/index.html
> > ----------------www.GeoStart.nl/english/-Google maps - Swis Webdesignwww.twitter.com/bbrala

Björn Brala

unread,
May 9, 2010, 8:04:00 AM5/9/10
to google-map...@googlegroups.com
You will need to specify the zoom level on which the marker should be visible. It doesn´t do that automaticly.

If you want automatic clustering you might want to use the Clusterer class in the same library.

2010/5/7 TK <taketo...@gmail.com>

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

TK

unread,
May 9, 2010, 8:14:37 AM5/9/10
to Google Maps JavaScript API v3

Oh, I see I should use the MarkerClusterer class not MarkerManager.

Will try to do so.

Thank you very much.


On 5月9日, 午後9:04, Björn Brala <bbr...@gmail.com> wrote:
> You will need to specify the zoom level on which the marker should be
> visible. It doesn´t do that automaticly.
>
> If you want automatic clustering you might want to use the Clusterer class
> in the same library.
>
> 2010/5/7 TK <taketo.ogu...@gmail.com>
> > <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3%252Buns...@googlegroups.com>
>
> > > > > .
> > > > > > For more options, visit this group athttp://
> > > > > groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > > > > --
> > > > > 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%2Bunsu...@googlegroups.com>
> > <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3%252Buns...@googlegroups.com>
>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > > > --
> > > > Bjorn Brala
> > > > ----------------www.GeoStart.nl/english/-Googlemaps - Swis
> > Webdesignwww.twitter.com/bbrala
>
> > > > --
> > > > 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
> ----------------www.GeoStart.nl/english/- Google maps - Swis Webdesignwww.twitter.com/bbrala

Fredrik Bonander

unread,
May 10, 2010, 8:01:45 AM5/10/10
to google-map...@googlegroups.com
Don't know if the problem got solved. But if anyone's interested I've built a markermanager using google maps MVC object, that supports, different zoom levels, custom marker and categorized markers.

..fredrik


--
Fredrik Bonander

the infinite power of the creative mind - 

Björn Brala

unread,
May 10, 2010, 11:08:28 AM5/10/10
to google-map...@googlegroups.com
If you are interested in opensourcing it, joing the Utility library team. I think you should email dani...@google.com to get access :)

Have you got a working example somewhere?

2010/5/10 Fredrik Bonander <carl.fredr...@gmail.com>

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

Fredrik Bonander

unread,
May 10, 2010, 11:25:21 AM5/10/10
to google-map...@googlegroups.com
I'll email him. 

Well, unfortunately no. But the current project I'm working on will be released in the next couple of weeks. I'll update you with a link then.

..fredrik

TK

unread,
May 10, 2010, 2:17:56 PM5/10/10
to Google Maps JavaScript API v3

For user who use many (maybe over 100) makers (with XML/KML) would be
great if could automatic clustering just set in myOptions i.e
clustering:0/1 without MarkerManager or MarkerClusterer class.

I don't know why support something like this. What do you think? :)

http://www.shift.jp.org/en/map/
This is a sample of v2 version of automatic clustering depends on zoom
level.



On May 11, 12:25 am, Fredrik Bonander
<carl.fredrik.bonan...@gmail.com> wrote:
> I'll email him.
>
> Well, unfortunately no. But the current project I'm working on will be released in the next couple of weeks. I'll update you with a link then.
>
> ..fredrik
>
> On 10 maj 2010, at 17.08, Björn Brala wrote:
>
>
>
> > If you are interested in opensourcing it, joing the Utility library team. I think you should email daniel...@google.com to get access :)
>
> > Have you got a working example somewhere?
>
> > 2010/5/10 Fredrik Bonander <carl.fredrik.bonan...@gmail.com>
> >>>>>> ----------------www.GeoStart.nl/english/-Googlemaps- Swis
> >>> ----------------www.GeoStart.nl/english/-Google maps - Swis Webdesignwww.twitter.com/bbrala
>
> >>> --
> >>> 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 athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> >> --
> >> 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 athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > --
> > Fredrik Bonander
> > carl.fredrik.bonan...@gmail.com
> > +46 70 943 5441
>
> > - the infinite power of the creative mind -
>
> > --
> > 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 athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > --
> > Bjorn Brala
> > ----------------
> >www.GeoStart.nl/english/- Google maps - Swis Webdesign
> >www.twitter.com/bbrala
>
> > --
> > 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 athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> --
> Fredrik Bonander
> carl.fredrik.bonan...@gmail.com
> +46 70 943 5441
>
> - the infinite power of the creative mind -
>
> --
> 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.

TK

unread,
May 10, 2010, 2:32:55 PM5/10/10
to Google Maps JavaScript API v3

Sorry, I mean - I don't know why Google Maps JavaScript API dosen't
support something like this.
> > >>> ----------------www.GeoStart.nl/english/-Googlemaps - Swis Webdesignwww.twitter.com/bbrala
>
> > >>> --
> > >>> 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 athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > >> --
> > >> 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 athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > > --
> > > Fredrik Bonander
> > > carl.fredrik.bonan...@gmail.com
> > > +46 70 943 5441
>
> > > - the infinite power of the creative mind -
>
> > > --
> > > 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 athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > > --
> > > Bjorn Brala
> > > ----------------
> > >www.GeoStart.nl/english/-Google maps - Swis Webdesign

Fredrik Bonander

unread,
May 10, 2010, 2:54:24 PM5/10/10
to google-map...@googlegroups.com
Yes, I agree. But the the Utillity library team's solution work great.

..fredrik
--
Fredrik Bonander

the infinite power of the creative mind - 

Rossko

unread,
May 10, 2010, 4:28:04 PM5/10/10
to Google Maps JavaScript API v3
> Sorry, I mean -  I don't know why Google Maps JavaScript API dosen't
> support something like this.

For a lot of people, it's just unwanted bloat.
For others, it won't work the way they want - there is more than one
way to cluster and several variables in the way it works.

Anyone who wants to add it, can easily add it.
Anyone who wants to modify it, can do so.

> http://www.shift.jp.org/en/map/
> This is a sample of v2 version of automatic clustering depends on zoom
level.

Yes, but its not built-in to the API.
It uses an add-on script for the API, KsGmaps.
It gives me slow script errors.

TK

unread,
May 10, 2010, 10:16:19 PM5/10/10
to Google Maps JavaScript API v3

Yes. It might be better to use utility library for anyone who wants to
do so.

But even if there's 2 markers located very close each other, those 2
markers overlap when you zoom out the map. And you will not be able to
click the marker behind the other one, and you won't be able to see it
at all.
I think automatic clustering is a necessary function.

Yes. It shows very slow. Also KsGmaps already finished its support, I
'm now trying with API3...
Reply all
Reply to author
Forward
0 new messages