无法在网页浏览中的地图上添加标记

时间:2016-02-15 11:10:00

标签: javascript android angularjs google-maps

我是Webview的初学者,试图通过$ interval动态绘制webview上的标记。我正在使用谷歌地图api v3和跟随角谷歌地图库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上运行它时它不起作用。我错过了什么?

1 个答案:

答案 0 :(得分:0)

也许您在移动设备上收听地图点击事件时遇到问题,所以我建议您查看以下帖子:

ng-map on-click doesn't work on mobile

how can i bind touch events for a marker in google maps?