未捕获类型错误:对象[对象全局]没有方法'onGoogleReady“采用了棱角分明的UI与Angular.js ui.maps [英] Uncaught TypeError: Object [object global] has no method 'onGoogleReady' using angular-ui's ui.maps with Angular.js
本文介绍了未捕获类型错误:对象[对象全局]没有方法'onGoogleReady“采用了棱角分明的UI与Angular.js ui.maps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用角UI的的 UI的地图Angular.js 库和接收错误
未捕获类型错误:对象[对象全局]没有方法'onGoogleReady使用与Angular.js ui.maps
我明白我需要包括:
函数onGoogleReady(){
angular.bootstrap(的document.getElementById(图),['app.ui-地图']);
}
但在哪里以及如何?
解决方案
函数initCall(){
的console.log(谷歌地图API初始化。);
angular.bootstrap(的document.getElementById(图),['doc.ui-地图']);
}angular.module('doc.ui地图',['ui.map','prettifyDirective'])
.controller('MapCtrl',['$范围',函数($范围){$ scope.myMarkers = [];$ scope.mapOptions = {
中心:新google.maps.LatLng(35.784,-78.670)
变焦:15,
mapTypeId设为:google.maps.MapTypeId.ROADMAP
};$ scope.addMarker =功能($时,$ params)方法{
$ scope.myMarkers.push(新google.maps.Marker({
图:$ scope.myMap,
位置:$ PARAMS [0] .latLng
}));
};$ scope.setZoomMessage =功能(变焦){
$ scope.zoomMessage ='你只放大到'+变焦+!;
的console.log(缩放,'放大');
};$ scope.openMarkerInfo =功能(标记){
$ scope.currentMarker =标记;
$ scope.currentMarkerLat = marker.getPosition()纬度()。
$ scope.currentMarkerLng = marker.getPosition()LNG()。
$ scope.myInfoWindow.open($ scope.myMap,标记);
};$ scope.setMarkerPosition =功能(标记,纬度,经度){
marker.setPosition(新google.maps.LatLng(纬度,经度));
};
}]);
来源: <大骨节病>的 Demo.js 骨节病>
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?
解决方案
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
这篇关于未捕获类型错误:对象[对象全局]没有方法'onGoogleReady“采用了棱角分明的UI与Angular.js ui.maps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文