我有一个 google play 地图的问题。在第一种情况下,整个加载正确,但第二个地图没有加载。我认为这将解决一些方法,但没有。我已经采取了这个清除地图。
var map = document.getElementById("mapa_ubicacion");
google.maps.event.trigger(map, 'resize');
这个地图每次加载的人拍照的移动设备的相机是为什么很多时候你可以占用。
$scope.cargarUbicacion = function () {
var posOptions = {timeout: 10000, enableHighAccuracy: false};
$cordovaGeolocation
.getCurrentPosition(posOptions)
.then(function (position) {
var latitud_actual = position.coords.latitude
var longitud_actual = position.coords.longitude
var mapOptions = {
center: new google.maps.LatLng(latitud_actual, longitud_actual),
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
map = new google.maps.Map(document.getElementById("mapa_ubicacion"), mapOptions);
$scope.setMarker(map, new google.maps.LatLng(latitud_actual, longitud_actual), 'Yo', '');
}, function(err) {
// error
});
var watchOptions = {
frequency : 1000,
timeout : 3000,
enableHighAccuracy: false // may cause errors if true
};
var watch = $cordovaGeolocation.watchPosition(watchOptions);
watch.then(
null,
function(err) {
// error
},
function(position) {
var latitud_actual = position.coords.latitude
var longitud_actual = position.coords.longitude
var mapOptions = {
center: new google.maps.LatLng(latitud_actual, longitud_actual),
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
map = new google.maps.Map(document.getElementById("mapa_ubicacion"), mapOptions);
$scope.setMarker(map, new google.maps.LatLng(latitud_actual, longitud_actual), 'Yo', '');
});
watch.clearWatch();
}
尝试在您的控制器中的初始函数中创建单个 map 实例,并将 map 对象添加到范围中。然后只更新您的方法中的 map 位置。这帮助我解决了类似的问题。
$scope.init = function() {
var mapOptions = {
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
var map = new google.maps.Map(document.getElementById("mapa_ubicacion"), mapOptions);
$scope.map = map;
}
$scope.init();
})
在您的方法中执行以下操作:
//set map center with your coords on $scope.map
$scope.setMarker($scope.map, new google.maps.LatLng(latitud_actual, longitud_actual), 'Yo', '');
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(69条)