小编Kit*_*_HK的帖子

第二次无法加载谷歌地图API

我正在学习AngularJS和Ionic,我正在将Google Maps API v3添加到我的应用程序中.

这是我的控制器:

$scope.drawMap = function(position) {
    $scope.$apply(function() {
        $scope.abc.lng = resp.data[0].longit;
        $scope.abc.lat = resp.data[0].latit;
        $scope.map = {
            center: {
                latitude: $scope.abc.lat,
                longitude: $scope.abc.lng
            },
            zoom: 17
        };
        $scope.marker = {
            id: 0,
            coords: {
                latitude: $scope.abc.lat,
                longitude: $scope.abc.lng
            }
        };
        $scope.marker.options = {
            draggable: false,
            labelAnchor: "80 120", //marker position
            labelClass: "marker-labels"
        };
    });
}
navigator.geolocation.watchPosition($scope.drawMap);
 $scope.$on('$ionicView.leave', function(){
   map.remove();
 });
Run Code Online (Sandbox Code Playgroud)

}); })

这是我的HTML:

<ui-gmap-google-map center='map.center' zoom='map.zoom' events="map.markersEvents">
    <ui-gmap-marker coords="marker.coords" options="marker.options" idkey="marker.id">
    </ui-gmap-marker>
</ui-gmap-google-map>
Run Code Online (Sandbox Code Playgroud)

指令也是:

starter.directive('googleMap', function(){
    return …
Run Code Online (Sandbox Code Playgroud)

google-maps google-maps-api-3 angularjs ionic

7
推荐指数
0
解决办法
553
查看次数

标签 统计

angularjs ×1

google-maps ×1

google-maps-api-3 ×1

ionic ×1