我尝试为您在此处找到的Phonegap + Angular OpenSource项目编写自定义地图指令:https://github.com/MariusSchmidt/Schreibwerkstatt/tree/Bettermap。我的问题是,当我尝试在ng-link调用的指令方法mapClicked($ event)中使用event.stopPropagation()调用时,我在大多数情况下在Internet Explorer中得到10 $ digest()错误。我想明白,我做错了什么?
该指令是angularmap: https://github.com/MariusSchmidt/Schreibwerkstatt/blob/Bettermap/www/js/directives.js
提供的模板是:
<div ng-style="containerStyle()" ng-click="mapClicked($event)">
<div ng-style="mapStyle()">
<img ng-repeat="icon in icons" ng-click="icon.toggleActive(); $event.stopPropagation();" ng-src="{{icon.getImage()}}" ng-style="iconStyle(icon)" />
<img src="./img/positionmarker.png" ng-style="positionMarkerStyle()" />
<img ng-click="goToPosition()" src="img/position.png" style="">
<a ng-href="#/poi" ><img src="img/info.png" style="float: right"></a>
</div>
</div>
控制器使用它是:
appControllers.controller('MapCtrl', function($scope, Map) {
$scope.userPosition = {latitude: 50.110290, longitude: 8.671265};
console.log($scope);
});
它在部分内使用:
<main>
<div class="ym-wrapper">
<div class="ym-wbox">
<angularmap user-position="userPosition"></angularmap>
</div>
</div>
</main>
希望你能帮我解决这个问题,我已经找了好几天了
致以最诚挚的问候,
的Marius
更新 图标在JSON文件中定义:
"icons": [
{
"src": "./img/02-nikolaikirche1.png",
"srcActive": "./img/02-nikolaikirche2.png",
"top": 255,
"left": 770,
"coords": {
"latitude": 50.110290,
"longitude": 8.682265
}
},
{
"src": "./img/03-roemer1.png",
"srcActive": "./img/03-roemer2.png",
"top": 210,
"left": 700,
"coords": {
"latitude": 50.110290,
"longitude": 8.682265
}
}
]
使用以下方法将其映射到图标属性:
this.icons = _.map(TOUR.icons, function (icon) {
return {
src: icon.src,
srcActive: icon.srcActive,
top: icon.top,
left: icon.left,
isActive: false,
coords: icon.coords,
getImage: function () {
return this.isActive ? this.srcActive : this.src;
},
toggleActive: function() {
this.isActive = !this.isActive
}
}
});