Using css class names instead of MarkerImage

690 views
Skip to first unread message

parky128

unread,
Nov 29, 2010, 9:01:48 AM11/29/10
to Google Maps JavaScript API v3
Hi,

Is it possible to specifiy a css class name for a Marker which can be
used for the icon displayed on the map rather than defining a
MarkerImage class?

I have a sprite containing the icons I require for various markers and
class names in a css file which defines each icon in terms of where
the image is located in the sprite file.

I hope this makes sense!

Thanks,
Rob

Pil

unread,
Nov 29, 2010, 9:38:10 AM11/29/10
to Google Maps JavaScript API v3
You can do that by using an API markerImage:

var g = google.maps;
var image = new g.MarkerImage("sprite-icons.png",
new g.Size(20, 34),
new g.Point(0, 34), <-- this are the sprite coords
new g.Point(10, 34));

parky128

unread,
Nov 29, 2010, 9:52:44 AM11/29/10
to Google Maps JavaScript API v3
Yes but as per my question, I dont want to use the MarkerImage class,
I want to know if I can specify a css class name against a Marker
object where it will retrieve the image to use.

peanut

unread,
Dec 1, 2010, 9:00:31 AM12/1/10
to google-map...@googlegroups.com
You may be able to use Marc Ridey's Label class to do what you want. 

http://blog.mridey.com/2009/09/label-overlay-example-for-google-maps.html

You can basically bind the label to a marker and add the label to the map with or without the marker.   I have successfully used this with css classes.  None of the css classes had images tho.

Rich
Reply all
Reply to author
Forward
0 new messages