AngularJS Google 地图 (ng-map) 图标 url 不工作

AngularJS Google Map (ng-map) icon url not working

由于某些原因,当我使用绝对 url 而不是相对时,我的标记没有显示。

在我看来我使用:

<marker ... icon="{url: '{{markerSrc}}'}"></marker>

当我这样做时(在我的控制器中):

$scope.markerSrc = "/images/marker.png";

一切正常并显示图标

但当我这样做时:

$scope.markerSrc = "http://complete/path/to/marker/images/marker.png";

我得到一个错误:

GET http://localhost:9000/%7Burl:%20'http://complete/path/to/marker/images/marker.png'%7D 404 (Not Found)

我尝试了不同的方法,比如

<marker ... icon="{url: "'{{markerSrc}}'" }"></marker>
<marker ... icon="{url: "{{markerSrc}}" }"></marker>
<marker ... icon="{url: {{markerSrc}} }"></marker>

但是 none 似乎有效...

尝试更改 marker 指令 icon 属性语法:

<marker ... icon="{url: '{{markerSrc}}'}"></marker>

<marker ... icon="{{markerSrc}}"></marker>

例子

var app = angular.module('appMaps', ['ngMap']);
app.controller('mapCtrl', function ($scope) {
    

    $scope.cities = [
       { id: 1, name : "Brisbane", location: [-33.867396, 151.206854] },
        { id: 2, name: "Sydney", location: [-27.46758, 153.027892] },
        { id: 3, name: "Perth", location: [-31.953159, 115.849915] }
    ];


    $scope.markerSrc = "http://maps.google.com/mapfiles/marker.png";

});
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<div ng-app="appMaps" ng-controller="mapCtrl">
        <map center="[-24.667856, 133.630694]" zoom="4">
            <marker id='ID{{city.id}}' ng-repeat="city in cities" position="{{city.location}}" icon="{{markerSrc}}"   >
            </marker>
            
        </map>
</div>