【发布时间】:2016-02-15 11:09:59
【问题描述】:
我是 Webview 的初学者,试图通过 $interval 在 webview 上动态绘制标记。我正在使用 google map api v3 和 angular google map library ng-map.js:
<html style="overflow: auto !important;" ng-app="myApp">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=weather,visualization,panoramio"></script>
<script src="JS/angular.min.js"></script>
<script src="JS/ng-map.min.js"></script>
<script>
var app = angular.module('myApp', ['ngMap']);
app.controller("PolylineComplexCtrl", function (NgMap, $interval, $scope) {
$interval(function (position) {
navigator.geolocation.getCurrentPosition(function (position) {
new google.maps.Marker({
position : {
lat : position.coords.latitude,
lng : position.coords.longitude
},
map : $scope.map,
draggable : false,
animation : google.maps.Animation.BOUNCE
});
});
}, 1000);
var vm = this;
vm.path = [[41.879535, -87.624333]];
vm.addMarkerAndPath = function (event) {
vm.path.push([event.latLng.lat(), event.latLng.lng()]);
};
});
</script>
</head>
<body ng-controller="PolylineComplexCtrl as vm">
<ng-map zoom="7" center="21.1500,79.0900" on-click="vm.addMarkerAndPath()">
<shape name="polyline" id="foo"
path="{{vm.path}}"
stroke-color="#FF0000"
stroke-opacity="1.0"
stroke-weight="3">
</shape>
</ng-map>
</body>
</html>
在浏览器上一切正常,但是当我在 webview 上运行它时它不起作用。我错过了什么?
【问题讨论】:
-
什么不能在移动设备上运行?您是否使用带有某些框架(Ionic,...)的cordova?
标签: javascript android angularjs google-maps