0

I have a Google Maps marker function that successfully creates markers on a map like this:

 // A function to create the marker and set up the event window
  function createMarker(point,html) {
    var marker = new GMarker(point,{title:html});
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
    });
    return marker;
  }

Here is a tinyurl of the exiting code: http://tinyurl.com/b8f9b4l

Using this solution: Google maps: place number in marker?

I've updated this line of code but it is not numbering. What am I doing wrong?

var marker = new GMarker(point,{title:html,icon:'icon: \'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld='+ (position) +'|FF776B|000000',});
2
  • You're using API v2 which is going to stop working in about 3 weeks time: developers.google.com/maps/documentation/javascript/v2 Strongly suggest you rewrite it ASAP to API v3
    – duncan
    Apr 25, 2013 at 8:13
  • Yep..that is what I ended up doing...the code was a mess anyway. Sometimes being forced to rewrite works out okay :-) Apr 25, 2013 at 21:21

1 Answer 1

1

The icon property just needs to be the url. You don't need the extra "icon:", and you should drop the extra comma at the end (IE seems to throw an exception when it finds a dangling comma). Also, the parenthesis you don't need - but probably aren't hurting anything.

{
title:html,
icon: 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=' + position +'|FF776B|000000'
}

I see where you got the idea. Idk why s/he got a point for that. The extra "icon:" messes it up.

Try this as a test, it should make sure you don't have any problems with the variables inside the url.

{
title:html,
icon: 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=4|FF776B|000000'
}
6
  • Still something wrong with it..when I add the icon: it defaults the map to a World view with now markers: tinyurl.com/arsy2wb Apr 24, 2013 at 19:31
  • Where are you getting "position" from? I don't see that variable in your code. You might want to use your "pos" var, but you may need to pass that into your function like you did "point" and "html". For a quick test, just replace your "position" with a number in the url.
    – dmgig
    Apr 24, 2013 at 19:39
  • its in the URL like this for each marker: ?q=@53,-2&[email protected],-2.5 Apr 24, 2013 at 19:49
  • you're not trying to display "53,-2" in the marker icon are you? You can probably only show up to a two digit number. As a test, put this as the url for the icon: chart.googleapis.com/… then we go from there.
    – dmgig
    Apr 24, 2013 at 19:52
  • Not at all, check the URL here and you'll see. I'm trying to just add numbers to the markers already displayed in the order they appear in the URL: tinyurl.com/b8f9b4l Apr 24, 2013 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.