2013-08-23 58 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 
      }); 

希望這有助於!