I want to ask you all about how to add number dynamically on each markers in Google Maps v3 with JavaScript. For example, the first marker is 1, the second one is 2, etc. In this case I have position data like this :
[
new google.maps.LatLng(1.3667, 103.8000),
new google.maps.LatLng(1.3667, 103.8000),
new google.maps.LatLng(1.3667, 103.8000),
new google.maps.LatLng(1.3667, 103.8000),
new google.maps.LatLng(51.0000, 9.0000),
new google.maps.LatLng(51.0000, 9.0000),
new google.maps.LatLng(51.5142, -0.0931),
new google.maps.LatLng(51.5142, -0.0931),
new google.maps.LatLng(54.0000, -2.0000),
new google.maps.LatLng(51.6000, -1.2500),
new google.maps.LatLng(51.7500, -1.2500)
];
But that data dynamically change. So for the first position lat/long I will give the number 1 on first marker, number 2 for the second marker, etc. And also i have use the icon each marker with this :
"http://chart.apis.google.com/chart?chst=d_map_xpin_letter_withshadow&chld=pin_star|%E2%80%A2|CC3300|000000|FF9900"
Do I have to change the marker icon? I really need your suggest or example code to fix the problem. Please help. Thank You very much for the help.
You can keep your starred pin icon and add an unobtrusive label next to it. This label can say anything but I kept it to simply a number. It is the MarkerWithLabel library (download here)
DEMO http://jsfiddle.net/yV6xv/21/
You need to define a CSS for it too.
And replace your regular Marker with MarkerWithLabel:
Including in the HTML file
You can do this in multiple ways. Changing the marker image is one, but requires you to make all those marker images. Another is to use the StyledMarker library which is part of the Google Maps API Utility Library.