Uncaught TypeError: Object [object global] has no method 'onGoogleReady' using angular-ui's ui.maps with Angular.js

点点圈 提交于 2019-12-10 18:37:58

问题


I'm trying to use angular-ui's ui-map library with Angular.js and receive the error

" Uncaught TypeError: Object [object global] has no method 'onGoogleReady' using ui.maps with Angular.js ".

I understand I need to include :

function onGoogleReady() {
  angular.bootstrap(document.getElementById("map"), ['app.ui-map']);
}

but where and how?


回答1:


 function initCall() {
 console.log("Google maps api initialized.");
   angular.bootstrap(document.getElementById("map"), ['doc.ui-map']);
}

angular.module('doc.ui-map', ['ui.map', 'prettifyDirective'])
 .controller('MapCtrl', ['$scope', function ($scope) {

$scope.myMarkers = [];

$scope.mapOptions = {
  center: new google.maps.LatLng(35.784, -78.670),
  zoom: 15,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};

$scope.addMarker = function ($event, $params) {
  $scope.myMarkers.push(new google.maps.Marker({
    map: $scope.myMap,
    position: $params[0].latLng
  }));
};

$scope.setZoomMessage = function (zoom) {
  $scope.zoomMessage = 'You just zoomed to ' + zoom + '!';
  console.log(zoom, 'zoomed');
};

$scope.openMarkerInfo = function (marker) {
  $scope.currentMarker = marker;
  $scope.currentMarkerLat = marker.getPosition().lat();
  $scope.currentMarkerLng = marker.getPosition().lng();
  $scope.myInfoWindow.open($scope.myMap, marker);
};

$scope.setMarkerPosition = function (marker, lat, lng) {
  marker.setPosition(new google.maps.LatLng(lat, lng));
};
}]) ;

Source : Demo.js



来源:https://stackoverflow.com/questions/19166633/uncaught-typeerror-object-object-global-has-no-method-ongoogleready-using-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!