Color markers (other than red)

3,343 views
Skip to first unread message

Mark Adler

unread,
Dec 25, 2010, 7:25:39 PM12/25/10
to google-map...@googlegroups.com
The Static Maps API very nicely and easily provides different color markers.  How do I get different color markers in the Maps JavaScript API v3?

geoco...@gmail.com

unread,
Dec 25, 2010, 7:46:07 PM12/25/10
to Google Maps JavaScript API v3
On Dec 25, 7:25 pm, Mark Adler <goo...@madler.net> wrote:
> The Static Maps API very nicely and easily provides different color markers.
>  How do I get different color markers in the Maps JavaScript API v3?

Either:
1. make them
2. if you want the "normal" markers, google provides some
http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png
http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png
for a small set of colors.

-- Larry

Mark Adler

unread,
Dec 25, 2010, 8:38:49 PM12/25/10
to google-map...@googlegroups.com
Thanks!  That's a start.  Though not nearly as convenient as in the static maps API.  There should be a color option for markers, as well as a label option in this API, like in the other API.  So there is no way to simply specify a color and a label?

Is there a list of what icons are there?  By trial and error I also found red, yellow, orange, and purple.  But not the other colors that are in the static API, specifically white, black, brown, or gray.  Are there icons there with letters and numbers in them as well?

Replacing the default marker image looks a little difficult.  Do I also have to provide a shape and a shadow?  If so, can I find those somewhere?  For the image, do I need to provide a size, or can it just figure that out from the image loaded?

geoco...@gmail.com

unread,
Dec 26, 2010, 12:47:34 AM12/26/10
to Google Maps JavaScript API v3
On Dec 25, 8:38 pm, Mark Adler <goo...@madler.net> wrote:
> Thanks!  That's a start.  Though not nearly as convenient as in the static
> maps API.  There should be a color option for markers, as well as a label
> option in this API, like in the other API.  So there is no way to simply
> specify a color and a label?

Nope (at least that I know of).

>
> Is there a list of what icons are there?  

There used to be a list on the mapki, but it looks like that site has
a problem.
Pamela fox posted a list to the v2 group a few years ago:
http://groups.google.com/group/google-maps-api/msg/5a07a33dd0281b45

> By trial and error I also found
> red, yellow, orange, and purple.  But not the other colors that are in the
> static API, specifically white, black, brown, or gray.  Are there icons
> there with letters and numbers in them as well?

I believe so.

>
> Replacing the default marker image looks a little difficult.  Do I also have
> to provide a shape and a shadow?  

Yes.

> If so, can I find those somewhere?  

Feel free to start with the ones I use here (I think they should work,
but I haven't tried them):
http://www.geocodezip.com/v3_markers_normal_colored.html

> For the image, do I need to provide a size, or can it just figure that out from
> the image loaded?
It is better to provide the size.

-- Larry

Marc Ridey

unread,
Dec 26, 2010, 6:46:17 AM12/26/10
to google-map...@googlegroups.com
You can also use the Google Chart API to create any color marker and the corresponding shadow.
See http://code.google.com/apis/chart/docs/gallery/dynamic_icons.html
> --
> 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.
>
>

geoco...@gmail.com

unread,
Dec 26, 2010, 11:42:32 AM12/26/10
to Google Maps JavaScript API v3
On Dec 25, 7:46 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Dec 25, 7:25 pm, Mark Adler <goo...@madler.net> wrote:
>
> > The Static Maps API very nicely and easily provides different color markers.
> >  How do I get different color markers in the Maps JavaScript API v3?
>
> Either:
> 1. make them
> 2. if you want the "normal" markers, google provides somehttp://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.pnghttp://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png
> for a small set of colors.

Here is a map with examples for the eight colors on pamela's list:
http://www.geocodezip.com/v3_markers_normal_colored_google.html
(they are 32x32, not 20x34)

  -- Larry

Mark Adler

unread,
Dec 26, 2010, 12:43:13 PM12/26/10
to google-map...@googlegroups.com
Excellent, thanks!  Yes, every single one from Pamela's list is still there.  Though none of the ones in her list have letters or numbers in the icons.

I got different color markers working with using the shadow I found there and the shape in your example.  Thanks again. 

Mark

Mark Adler

unread,
Dec 26, 2010, 1:13:06 PM12/26/10
to google-map...@googlegroups.com
Actually, your shape was a bit off.  I made my own that seems to cover the pin pretty well:

[15,0, 19,1, 23,4, 24,9, 23,14, 20,17, 17,23, 15,31, 13,23, 10,17, 7,14, 6,9, 7,4, 11,1]

Mark

geoco...@gmail.com

unread,
Dec 26, 2010, 1:30:12 PM12/26/10
to Google Maps JavaScript API v3
Didn't think about that, I updated that example to use your shape.

-- Larry


>
> Mark
Message has been deleted

Mark Adler

unread,
Dec 26, 2010, 2:39:48 PM12/26/10
to google-map...@googlegroups.com
And here is an updated shape that exactly covers the non-transparent pixels (with all redundant points removed):

        var shape = {
            coord: [19,0, 24,5, 24,12, 23,13, 23,14, 20,17, 20,18, 19,19, 19,20, 18,21,
                    18,22, 17,23, 17,26, 16,27, 16,31, 14,31, 14,26, 13,25, 13,23,
                    12,22, 12,20, 10,18, 10,17, 7,14, 7,13, 6,12, 6,6, 7,5, 7,4, 11,0],
            type: 'poly'
        };

Mark
Message has been deleted

Mark Adler

unread,
Dec 28, 2010, 1:03:47 AM12/28/10
to google-map...@googlegroups.com
If anyone is interested, a program is linked here that reads a png 
image with an alpha channel and writes a list of points for a polygon 
that exactly circumscribes the non-zero alpha values.  This would be 
used to generate the coordinates for a shape to be used in a custom 
marker. 

    http://madler.net/shape.c 

Mark

Gary Little

unread,
Dec 28, 2010, 11:21:37 PM12/28/10
to Google Maps JavaScript API v3
If you're trying to add a label to any Marker, you can use the
MarkerWithLabel class:

http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/

Gary

imdad turi

unread,
Oct 18, 2017, 8:00:56 PM10/18/17
to Google Maps JavaScript API v3
thank you very much, worked..
Reply all
Reply to author
Forward
0 new messages