In add marker function i added the code and all the marker are getting displayed.

So i thought lets change the default image of the marker so i added two line

//image line 1 and 2 ... please see code below

 var image = 'news2.png';    //image line 1

  // create the marker for that place
  var marker = new google.maps.Marker({
    position: myLatlng,
    icon: image,   //image line 2
    title: place.place_name + ', '+ place.admin_name1

but the marker are gone after adding these two line i dont know why.

with this code the image news2.png i stored in js directory

i stored the image in img directory and used img/news.png in //image line 1 but still not markers are visible.

I removethese two line , all markers come back .

please help what wrong i am doing in changing the image of marker. thanks

1 Answer 1


You need to use /img/news2.jpg (notice the preceding slash) since img is a subdirectory of public (assuming that news2.jpg is stored in img). You should be able to do it in one line this way:
icon: '/img/news2.png',. That worked for me.

  • I used the url (online icon) and it worked. Ill try ur suggestion and see happens, thanks for the help. Dec 14, 2015 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .