Add different color Marker on Map

19,649 views
Skip to first unread message

huzzy143

unread,
Jun 12, 2010, 1:55:57 AM6/12/10
to Google Maps JavaScript API v3
Hi,

I have situation where i want to add Markers with different color.

By default when i add a Marker it is of Red color or sometimes its
Green color. How can i control the color?

In some situations i want Red Color Marker but in others i want a
Green Color Marker. I don't want to use custom images for this instead
use built in Markers, just change the colors.

Can anyone please help me out?

Thanks,
Huzefa

geoco...@gmail.com

unread,
Jun 12, 2010, 2:06:06 AM6/12/10
to Google Maps JavaScript API v3

en4ce

unread,
Jun 12, 2010, 6:26:25 AM6/12/10
to Google Maps JavaScript API v3
just specify the icon ?

var marker = new google.maps.Marker({
position: latlng,
map: map,
flat: true,
title: "meh"
draggable: false
})
iconFile = 'http://maps.google.com/mapfiles/ms/icons/green-dot.png';
marker.setIcon(iconFile)

huzzy143

unread,
Jun 12, 2010, 10:52:17 AM6/12/10
to Google Maps JavaScript API v3
Thanks a lot guys, this was a saviour for me..

Thanks,
Huzefa

On Jun 12, 9:06 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Jun 11, 10:55 pm, huzzy143 <huzzy...@gmail.com> wrote:
>
> > Hi,
>
> > I have situation where i want to add Markers with different color.
>
> > By default when i add a Marker it is of Red color or sometimes its
> > Green color. How can i control the color?
>
> > In some situations i want Red Color Marker but in others i want a
> > Green Color Marker. I don't want to use custom images for this instead
> > use built in Markers, just change the colors.
>
> > Can anyone please help me out?
>
> Do these help?http://www.geocodezip.com/v3_markers_colored.htmlhttp://www.geocodezip.com/v3_markers_normal_colored.htmlhttp://www.geocodezip.com/v3_markers_normal_colored_infowindows.html
>
>   -- Larry
>
>
>
> > Thanks,
> > Huzefa

Pil

unread,
Jun 12, 2010, 11:17:48 AM6/12/10
to Google Maps JavaScript API v3
Have you tried to use one image for all markers instead of an image
for every marker seperately? The technique is called sprite and the
functionality is integrated in v3.

It's a up to date and fast way to change the marker colors - and it
reduces server requests.





On Jun 12, 7:55 am, huzzy143 <huzzy...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages