如何使用角谷歌地图的指示相对路径? [英] How to use relative path in Angular Google Maps directives?
问题描述
我试图设置自定义标记上的AngularJS谷歌地图:
I'm trying to set a custom marker on an AngularJS Google Map:
<google-map
draggable="true"
style="display:block; width: 100%; height:100%;">
<markers>
<marker ng-repeat="marker in markers" coords="marker" icon="../img/marker-map.png">
</marker>
</markers>
</google-map>
这code引发以下错误:
This code throws the following error:
错误:令牌[$解析:语法]语法错误'。不是主要的前$的前pression [../img/marker-map.png] 1 P列$ pssion开始[../img/marker-map.png].$c$ C>
在href=\"http://angular-google-maps.org/api#marker\" rel=\"nofollow\">角谷歌地图API文档的图标参数,它说:
On the Angular Google Maps API documentation, in Marker directive's icon
parameter , it says:
实施例pression返回到图像的绝对路径用作标记
图标
Expression returning the absolute path to an image used as the marker icon
我想我误解了这句话。是不是可以设置标记图标图像相对路径,如上面的code的例子吗?什么可能是一个前pression引用标记图像?
I think I misunderstood that statement. Isn't it possible to set a relative path for the marker icon image, as in the code example above? What could be an expression to reference the marker image?
推荐答案
我知道了,对标记指示图标参数我应该使用引用标记图像的变量。
I got it, on the marker directive's icon parameter I should use a variable that references the marker image.
HTML
<marker ng-repeat="marker in markers" coords="marker" icon="markerIcon">
</marker>
在我的控制器:
$scope.markerIcon = "img/marker-map.png";
这篇关于如何使用角谷歌地图的指示相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!