marker classname

2,166 views
Skip to first unread message

inotipiedideipitoni

unread,
Aug 11, 2010, 10:01:09 AM8/11/10
to Google Maps JavaScript API v3
How can I set a classname of a group of markers?

I have a lot of markers with same proprety and I wanna give them a
class name, so whit jquery I'm gonna change the visibility of the
markers.

if I made something this:

switch (max)
{
case '0':
marker.icon = "http://www.google.com/mapfiles/marker_white.png";
marker.setAttribute = ("classname","blanco");
break;

case '1':
marker.icon ="http://www.google.com/mapfiles/marker_yellow.png";
marker.className = "green" ;
break;

case '2':
marker.icon ="http://www.google.com/mapfiles/marker.png";
marker.className = "yellow" ;
break;

case '-1' :
marker.icon = "http://www.google.com/mapfiles/marker_green.png";
marker.className = "red";
break;
}

but seems that the "marker.className" instruction doesn't take effect.

Chad Killingsworth

unread,
Aug 11, 2010, 11:21:28 AM8/11/10
to Google Maps JavaScript API v3
There is not a way through the API to do this. Best you could do is
parse the DOM in the specific pane for your markers and add the class
there. It wouldn't be too hard with jQuery. Keep in mind that the DOM
structure can (and has) changed without warning so your page could
break at sometime in the future.

Chad Killingsworth

On Aug 11, 9:01 am, inotipiedideipitoni

inotipiedideipitoni

unread,
Aug 11, 2010, 11:44:28 AM8/11/10
to Google Maps JavaScript API v3
I'm thinking that the best way is to try another approach...

thanks Chad.
if you could help me with others problems, it will be great!

On 11 Ago, 17:21, Chad Killingsworth

Nathan Raley

unread,
Aug 11, 2010, 2:09:25 PM8/11/10
to google-map...@googlegroups.com
Try this:

Create your Class for your Markers that you are wanting.

Make sure the Class has all of your attributes you need.

Create an Array to store your markers in.

Create your Marker:
var marker = new google.maps.Maker()

Then you can retrieve the class you are wanting for the marker.

var markerClass = new MarkerClass();

Have your MarkerClass return the Marker's class with all the Properties.

Then do:
marker.class = markerClass

Then push the marker to your Markers array.

Then when you want to access the class simply call
Markers[position].class.property

This make sense?

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


inotipiedideipitoni

unread,
Aug 17, 2010, 6:58:41 AM8/17/10
to Google Maps JavaScript API v3
so sorry: i've tried but it don't works.

On 11 Ago, 20:09, Nathan Raley <nlrale...@gmail.com> wrote:
> Try this:
>
> Create your Class for your Markers that you are wanting.
>
> Make sure the Class has all of your attributes you need.
>
> Create an Array to store your markers in.
>
> Create your Marker:
> var marker = new google.maps.Maker()
>
> Then you can retrieve the class you are wanting for the marker.
>
> var markerClass = new MarkerClass();
>
> Have your MarkerClass return the Marker's class with all the Properties.
>
> Then do:
> marker.class = markerClass
>
> Then push the marker to your Markers array.
>
> Then when you want to access the class simply call
> Markers[position].class.property
>
> This make sense?
>
> On Wed, Aug 11, 2010 at 10:44 AM, inotipiedideipitoni <
>
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages