Marker colour stays black Google Maps API -


i wrote script change marker colour depending on score between 0 , 1 on google maps api, marker colour @ moment black, have attached contents of javascript file below:

function initialize() {     var mapoptions = {         zoom: 7,         center: new google.maps.latlng(52.63506336920521, -1.8656949083418475),         maptypeid: google.maps.maptypeid.roadmap     }     map = new google.maps.map(document.getelementbyid("map-canvas"), mapoptions);      writeplacemarkers(); } console.log("1");  function placemarker(lat, long, name, score) {     var pincolor = get_colour(score);     var pinimage = new google.maps.markerimage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%e2%80%a2|" + pincolor,                                                new google.maps.size(21, 34),                                                new google.maps.point(0, 0),                                                new google.maps.point(10, 34));     var pinshadow = new google.maps.markerimage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",                                                 new google.maps.size(40, 37),                                                 new google.maps.point(0, 0),                                                 new google.maps.point(12, 35));     var marker = new google.maps.marker({         position: new google.maps.latlng(lat, long),         map: map,         title: name,         icon: pinimage,         shadow: pinshadow     });     var info = contentstring(name);     google.maps.event.addlistener(marker, 'click', function () {         info.open(map, marker);         console.log("2");     }); }  function get_colour(score) //score between 0 , 1 {     score = score * 511     var r;     var g;     var b = 0;     if (score > 255) {         g = 255;         r = 511 - score;     } else if (score < 255) {         g = score;         r = 255;     } else //score==255     {         g = 255;         r = 255;     }     console.log("3");     r = parseint(r).tostring(16);     g = parseint(g).tostring(16);     b = parseint(b).tostring(16);      if (r.length == 1) {         r = "0" + r;     }      if (g.length == 1) {         g = "0" + g;     }     console.log("4");     if (b.length == 1) {         b = "0" + b;     }     //console.log("#" + r + g + b);     return ("#" + r + g + b);     console.log("5"); }  var windowcontent = '<div id="content">';  function contentstring(windowcontent) {     windowcontent;     var infowindow = new google.maps.infowindow({         content: windowcontent     });     return infowindow; };  //54.78414136681993, -1.5866319722800213 function loadscript() {     var script = document.createelement("script");     script.type = "text/javascript";     script.src = "http://maps.googleapis.com/maps/api/js?key=aizasya0x5j1mom3hf3l2-f-hhv6plb5djoy9ng&sensor=false&callback=initialize";     document.body.appendchild(script); }   window.onload = loadscript; 

you adding "#" not in definition color

in get_color function

return("#" + r + g + b); 

should be:

return(r + g + b); 

working example

as aside, there statement in documentation api:

important: image charts portion of google chart tools has been officially deprecated of april 20, 2012. continue work per our deprecation policy.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -