【问题标题】:Angular Google maps custom marker iconAngular 谷歌地图自定义标记图标
【发布时间】:2015-06-06 13:45:18
【问题描述】:

我无法创建自定义标记。即使我将图像路径传递给 icon 参数,我仍然得到默认的橙色标记。 如果您发现任何问题,请告诉我。

指令模板:

<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&sensor=true 和 angular-google-maps/dist/angular-google-maps.js

【问题讨论】:

  • 我刚刚注意到我也不能使用动画。

标签: angularjs google-maps angular-google-maps


【解决方案1】:

错过了那个图标是一个对象。

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

【讨论】:

【解决方案2】:

我解决了通过 options 属性传递图标 url

在控制器上设置这样的东西

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>

【讨论】:

【解决方案3】:

我已经解决了自定义图标问题 请与 plunker Click 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>

【讨论】:

    猜你喜欢
    • 2015-10-19
    • 1970-01-01
    • 1970-01-01
    • 2018-01-13
    • 2013-08-21
    • 2016-09-20
    • 2014-07-18
    相关资源
    最近更新 更多