Search code examples
google-mapsgoogle-maps-markersgoogle-maps-api-2

How to add labels on Google Maps Pinpoints?


Creating a google map with store locations within 50 miles of user entered address. Have map & pinpoints showing correctly but all of the pinpoints just have a dot on them. I'd like to be able to label them A, B, C, D, etc so that I can list out locations & addresses in sidebar.

How would I do this? Here's the code I'm using to add my pinpoints.

    var point = new GLatLng(latitude, longitude);
            var marker = new GMarker(point);
            GEvent.addListener(marker, "click", function () {
                map.openInfoWindowHtml(point, myHtml);
            });
map.addOverlay(marker);

Solution

  • Excellent, thanks. Included this js library.

    http://code.google.com/p/gmaps-utility-library/

    And then all I needed to do was update the

    var marker = new GMarker(point);
    

    to this

    var newIcon = MapIconMaker.createLabeledMarkerIcon({label: "A", primaryColor: "#FD766A"});
    var marker = new GMarker(point, {icon: newIcon});