2013-08-23 59 views
-1

我已经看过以前提出的类似于我的问题,以及以下谷歌地图api开发人员信息页叠加层上的所有建议,但没有答案帮助 - m试图简单地将标记的颜色从标准更改为绿色,但是每次尝试将fillColor等添加到我的代码时,它都不会显示标记或根本不会显示地图。任何人有任何想法我做错了什么?谷歌地图api标记颜色变化的问题

function createMap() { 
     // map options 
     var options = { 
      zoom: 4, 
      center: new google.maps.LatLng(39.909736, -98.522109), // centered US 
      mapTypeId: google.maps.MapTypeId.ROADMAP, 
      mapTypeControl: false 
     }; 

     // init map 
     map = new google.maps.Map(document.getElementById('map_canvas'), options); 
    } 

    function addMarker() { 
    fetchNewQuote(); 
    var indext; 
    for (indext = 0; indext <array.length; ++indext) { 
     splitarr = array[indext].split(":"); 
     geosplit = splitarr[1].split(", "); 
     if (indext < 50) { 
     $('#tweet_table').append(array[indext] + "</br></br>"); 
     }   
     var marker = new google.maps.Marker({ 
      position: new google.maps.LatLng(geosplit[0], geosplit[1]), 
      map: map, 
      title: 'Click me to see what this individual tweeted!' 
      }); 

      (function(marker, splitarr, indext) { 
       var tweetclick = "TOBACCO VISUALIZATION</br>" + "Keyword: " + splitarr[0] + "</br> Coordinates: " + splitarr[1] + "</br> Tweet: " + splitarr[2]; 
       google.maps.event.addListener(marker, 'click', function() { 
        infowindow = new google.maps.InfoWindow({ 
         content: tweetclick 
        }); 
        infowindow.open(map, marker); 
       }); 
      })(marker, splitarr, indext); 
      marker.setMap(map); 
      markersArray.push(marker); 
     } 
    } 
+0

fillColor不适用于标记。请参阅[文档](https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions)。 [有关更改标记颜色的最新问题](http://stackoverflow.com/questions/18392077/change-marker-icon-api-google-maps-v3-with-a-select/18393215#18393215)(举例...) – geocodezip

回答

0

您可以加载自己的标志是这样的:

var icon = https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|00FF00 

你有管后传递标志的RGB格式的颜色。如果你想要一个蓝色标记,只需传递0000FF而不是00FF00。

然后,使用这样的:

var marker = new google.maps.Marker({ 
       position: new google.maps.LatLng(geosplit[0], geosplit[1]), 
       map: map, 
       title: 'Click me to see what this individual tweeted!' 
       icon: icon 
      }); 

希望这有助于!