Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've recently just did this icon stuff myself. And I initially used the same type of code you used, but that didn't work. Apparently new GIcon() was not functioning properly.</p> <p>There is a very simple way to change icon though and it doesn't use variables. This is what I did.</p> <p>Declare markerVariable as a global variable. When you create new markers, one of the lines should say icon : ...</p> <p>Here is a sample of my code. Of course, you will have to change certain lines to have it working for your program (and you can't use marker with labels unless you change certain functions).</p> <p>Lastly, icon : ... can be a link or location on your computer.</p> <pre><code>var iconArray = [ ["http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png"], ["http://www.google.com/intl/en_us/mapfiles/ms/micons/yellow-dot.png"], ["http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png"], ["http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png"], ["http://www.google.com/intl/en_us/mapfiles/ms/micons/purple-dot.png"], ["http://www.google.com/intl/en_us/mapfiles/ms/micons/pink-dot.png"], ["http://www.google.com/intl/en_us/mapfiles/ms/micons/ltblue-dot.png"] ]; function getMarkers() { for (i = 0; i &lt; locations.length; i++) { marker[i] = new MarkerWithLabel({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), draggable: false, map: map, icon: new google.maps.MarkerImage(iconArray[i]), //icon: new google.maps.MarkerImage("http://www.google.com/intl/en_us/mapfiles/ms/micons/pink-dot.png"), //labelContent: locations[i][3], labelAnchor: new google.maps.Point(30, 0), labelClass: "labels", // the CSS class for the label labelStyle: {opacity: 0.75} }); } } function initialize() { getMarkers(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload