Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create numbered map markers in Google Maps V3?

I'm working on a map that has multiple markers on it.

These markers use a custom icon, but I'd also like to add numbers on top. I've seen how this has been accomplished using older versions of the API. How can I do this in V3?

*Note -- the "title" attribute creates a tooltip when you mouseover the marker, but I want something that will be layered on top of the custom image even when you're not hovering on top of it.

Here's the documentation for the marker class, and none of these attributes seem to help: http://code.google.com/apis/maps/documentation/v3/reference.html#MarkerOptions

like image 697
marclar Avatar asked Mar 12 '10 23:03

marclar


People also ask

How do I create a custom marker on Google Maps?

For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements. After creating this icon now we will move towards adding this marker to our Map.

How do you add numbers to maps?

Re: Adding phone number of a place in Google map.Select the business or place where you wants to add phone number. The look at this you will get an option name add phone number. Then select the option and add phone number. After Verifying your edit google will be publish this.


1 Answers

Unfortunately it's not very easy. You could create your own custom marker based on the OverlayView class (an example) and put your own HTML in it, including a counter. This will leave you with a very basic marker, that you can't drag around or add shadows easily, but it is very customisable.

Alternatively, you could add a label to the default marker. This will be less customisable but should work. It also keeps all the useful things the standard marker does.

You can read more about the overlays in Google's article Fun with MVC Objects.

Edit: if you don't want to create a JavaScript class, you could use Google's Chart API. For example:

Numbered marker:

http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=7|FF0000|000000 

Text marker:

http://chart.apis.google.com/chart?chst=d_map_spin&chld=1|0|FF0000|12|_|foo 

This is the quick and easy route, but it's less customisable, and requires a new image to be downloaded by the client for each marker.

like image 105
dave1010 Avatar answered Sep 24 '22 12:09

dave1010