views:

16

answers:

2

i'm using the the following function to create my markers from a XML file. i wish to label each market 1,2,3,4,5,6 etc where 'i' is the number. can some please please tell me how to incorporate this. thank you

    function createMarker(point, name, address, type, i) {
  var marker = new GMarker(point, customIcons[type]);
  var html = "<b>" + name + "</b> <br/>" + address;
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
  return marker;
}
A: 

You can use Google's Chart server to create dynamic icons, and set that as your marker image.

Chart server docs on using dynamic icons: http://code.google.com/apis/chart/docs/gallery/dynamic_icons.html

For example, http://chart.apis.google.com/chart?chst=d_map_pin_letter&amp;chld=1|FF0000|000000 will render as alt text

and http://chart.apis.google.com/chart?chst=d_map_pin_letter&amp;chld=2|FF0000|000000 will get you alt text

Ossama
A: 

You can make your own Marker icons, and implement them onto your map, see here (It might be best to use the current Google Maps API v3 if you aren't already)

Do something like:

 function createMarker(point, name, address, i) {
  var image = "icon" + i + ".png";
  var html = "<b>" + name + "</b> <br/>" + address;
  var marker = new google.maps.Marker({
    position: point,
    map: map,
    icon: image,
    title: name
  });
  addinfowindow(marker, html);
  return marker;
}

(where you have made an icon for each marker called icon1.png to icon6.png and placed in the directory)

Also for multiple info windows you may need to create a new global function addinfowindow() with a infowindow defined globally (see here).

function addwindow(pmarker, phtml){


  google.maps.event.addListener(pmarker, 'click', function() {
    infowindow.setContent(phtml);
    infowindow.open(map, pmarker);
  });

}
adustduke