【发布时间】:2015-06-27 19:13:36
【问题描述】:
我在使用 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();
}
【问题讨论】:
标签: google-maps cordova ionic