Dears,
I would like to know if the statement navigator.geolocation.getCurrentPosition it is running in mobione.
I’m trying to use the howto for google map and I modified the assignment to the variable latlng.
If I comment the statement
//var latlng = new google.maps.LatLng(56.481975, -2.956910);
and I use mine
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
I see the alert shown tn the error function with the text [objet PositionError]
If I use the static geolocation new google.maps.LatLng(56.481975, -2.956910) it is shown with the alert just below the statement.
Why?
PS: my iphone asked for the first run the permission to use my position but shows a white screen
Thanks a lot.
Roberto
the custom script is here:
phoneui.documentReadyHandler = function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(DisplayMap, error);
} else {
alert(‘not supported’);
}
}
function error(msg) {
alert(‘Errore: ‘ + msg)
// console.log(arguments);
}
function DisplayMap(){
//The lat and long you want to show on the map//
var latlng = new google.maps.LatLng(56.481975, -2.956910);
//var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); // error function where uncomment
alert(latlng); // this run if is commented the above statement
//Map Options//
var myOptions = {
//Zoom – how close to the destination//
zoom: 15,
//Your center point//
center: latlng,
//Show default controls or not, best not to on phones as ot takes up a lot of room//
disableDefaultUI: true,
//Street view controls//
streetViewControl: false,
//Map Type//
mapTypeId: google.maps.MapTypeId.ROADMAP
};
//COPYRIGHT WHITE SPACE FIX, needs to point the map element, the same as the onebelow//
document.getElementById(‘m1-map-map’).style.lineHeight = ‘1’;
//Create a new map and assign it to our map panel. You will notice the screen namestarts with m1-name, you must use the m1-//
var map = new google.maps.Map(document.getElementById(“m1-map-map”),
myOptions);
//Create a point for our map marker//
var point = latlng;//new GLatLng(56.481975, -2.956910);
//Create a new marker with a title//
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:”Caird!”
});
//Create the marker on the map//
marker.setMap(map);
}​