2015-04-01 101 views
9

我無法創建自定義標記。即使我傳遞一個圖像路徑到圖標參數,我仍然得到默認的橙色標記。 請告訴我,如果你看到任何錯誤。角度Google地圖自定義標記圖標

指令的模板:

<div id="searchMap" class="googleMaps-destinations"> 
<div class="google-maps"> 
    <ui-gmap-google-map center="map.center" zoom="map.zoom" options="map.options"> 
     <ui-gmap-marker 
      ng-repeat="marker in search.origin_airports" 
      coords="marker.originMarker.location" 
      icon="marker.originMarker.icon.url" 
      fit="false" 
      idkey="'<<marker.originMarker.id>>'" > 
     </ui-gmap-marker> 
    </ui-gmap-google-map> 
</div> 

我使用://maps.googleapis.com/maps/api/js?v=3 &傳感器=與真正的角google- maps/dist/angular-google-maps.js

+0

我只注意到我不能用動畫爲好。 – JKoder 2015-04-01 19:06:28

回答

14

錯過了該圖標是一個對象。

icon= '{url: "//developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png" }' 
+0

工作。但我不認爲這是什麼醫生說http://angular-ui.github.io/angular-google-maps/#!/api – Toolkit 2015-05-15 04:38:12

12

我解決了在控制器通過圖標的網址通過選項屬性

設置這樣的事情

marker.options: { 
    icon:'//developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"' 
} 

然後

<div id="searchMap" class="googleMaps-destinations"> 
    <div class="google-maps"> 
    <ui-gmap-google-map center="map.center" zoom="map.zoom" options="map.options"> 
    <ui-gmap-marker 
     options="marker.options" 
     ng-repeat="marker in search.origin_airports" 
     coords="marker.originMarker.location"  
     fit="false" 
     idkey="'<<marker.originMarker.id>>'"> 
    </ui-gmap-marker> 
</ui-gmap-google-map> 

+0

看起來像這個問題,必須通過選項哈希設置圖標,已有報道:https://github.com/angular-ui/angular-google-maps/issues/1408 – ecbrodie 2015-08-16 19:19:53

0

我含有S olved自定義圖標問題 請與plunkerClick here

options: { draggable: false,  icon:'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png' } 

HTML是這裏

<ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="options"> 
     <ui-gmap-marker coords="marker.coords" options="marker.options" events="marker.events" idkey="marker.id"> 
     </ui-gmap-marker> 
    </ui-gmap-google-map>