我在使用angular-leaflet-directive创建多个映射时遇到问题。
我有一个城市列表,我想使用ng-reapeat来显示许多地图。
这是代码
<div ng-repeat="(key,city) in listCity" class="panel panel-info col-md-2" style=" height: 25%;">
<div class="panel-heading">{{city.name}}</div>
<div class="panel-body" style="width: 100%; height: 100%;">
<leaflet style="width: 100%; height: 90%;" center="{{city.place_id}}"></leaflet>
</div>
</div>它会向错误Syntax Error: Token '{' invalid key at column 2 of the expression [{{city.place_id}}] starting at [{city.place_id}}]发出警报。当我用其他字符串改变'center‘进行测试时,它没有错误。
请帮我修一下。
非常感谢!
发布于 2015-12-09 17:12:05
根据example in the docs,您必须在中心属性中提供lat、lng和zoom。
所以试着这样做:
<div ng-repeat="city in listCity" class="panel panel-info col-md-2" style=" height: 25%;">
<div class="panel-heading">{{city.name}}</div>
<div class="panel-body" style="width: 100%; height: 100%;">
<leaflet style="width: 100%; height: 90%;" center="{ lat: city.lat, lng: city.lng, zoom: 10 }"></leaflet>
</div>
</div>我假设你的listCity是一个数组。
https://stackoverflow.com/questions/34150125
复制相似问题