View Single Post
Posts: 29 | Thanked: 71 times | Joined on Apr 2010 @ Fresno, CA
#8
Originally Posted by kakoskin View Post
Hi,

Is there any way to get GPS location using Javascript in N900 browser ? I have heard that I could be possible but some plugin needs to be installed first. I would like to use the location on my ajax web page.
Hey you can also check
www.narrativecolors.com/map.html for javascript example.

also here is the code

----------------------XXXX------------------

function getMyLocation(){
if(navigator.geolocation) { // Try Browser's Geolocation
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function( position) {
initialLocation = new google.maps.LatLng(position.coords.latitude,positi on.coords.longitude);
map.setCenter(initialLocation);
}, function() { handleNoGeolocation(browserSupportFlag); });
} else if (google.gears) { // Try Google Gears Geolocation
browserSupportFlag = true;
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.latitude,position.long itude);
map.setCenter(initialLocation);
}, function() { handleNoGeoLocation(browserSupportFlag); });
} else { // Browser doesn't support Geolocation
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
alert("Geolocation service failed.");
} else {
alert("Your browser doesn't support geolocation !!");
}
}
var image = new google.maps.MarkerImage(
'images/iamhere.png', new google.maps.Size(48,48),
new google.maps.Point(0,0),
new google.maps.Point(24,48)
);

marker = new google.maps.Marker({ map: map, position: initialLocation, icon: image, title:"We are Here !! "});
}


-----------#### HOPE it works -------