0
我必须在我的离子应用程序(用于Android)中集成谷歌地图圈。我从this链接安装插件。我遵循所有步骤,但我有一个问题。当我调用map.addCircle()函数时,logcat返回错误“未捕获类型错误:未定义不是函数”。谷歌地图插件与离子
我该如何解决这个问题?
这是我controller.js:
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
// Wait until the map is ready status.
});
})
.controller('MapCtrl', function($scope, $ionicLoading, $compile) {
var geocoder;
geocoder = new google.maps.Geocoder();
function initialise() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
function onSuccess(position){
var myLatlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
$scope.latlng = myLatlng;
console.log($scope.latlng);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
});
map.addCircle({
'center': myLatlng,
'radius': 300,
'strokeColor' : '#AA00FF',
'strokeWidth': 5,
'fillColor' : '#880000'
});
$scope.map = map;
}
function onError(error){
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
}
google.maps.event.addDomListener(window, 'load', initialise);
})