Current location don't work in my Samsung galaxy S with android 2.1

38 views
Skip to first unread message

Kennwhy

unread,
Apr 18, 2011, 3:53:23 AM4/18/11
to Google Maps JavaScript API v3
I wanna use my native browser to play this example but never work.
Only work when I use firefox. please help...

Pil

unread,
Apr 18, 2011, 8:05:37 AM4/18/11
to Google Maps JavaScript API v3
What example do you mean? I think you didn't provide enough
information. Do you want to use the Geolocation API?

I'd suggest you try this library

http://code.google.com/p/geo-location-javascript/

Kennwhy

unread,
Apr 18, 2011, 11:10:34 AM4/18/11
to Google Maps JavaScript API v3
i was doing the first example in basic Concepts




var initialLocation;
var siberia = new google.maps.LatLng(60, 105);
var newyork = new google.maps.LatLng(40.69847032728747,
-73.9514422416687);
var browserSupportFlag = new Boolean();

function initialize() {
var myOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

// Try W3C Geolocation (Preferred)
if(navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new
google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
// Try Google Gears Geolocation
} else if (google.gears) {
browserSupportFlag = true;
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function(position) {
initialLocation = new
google.maps.LatLng(position.latitude,position.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeoLocation(browserSupportFlag);
});
// Browser doesn't support Geolocation
} else {
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}

function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
alert("Geolocation service failed.");
initialLocation = newyork;
} else {
alert("Your browser doesn't support geolocation. We've placed
you in Siberia.");
initialLocation = siberia;
}
map.setCenter(initialLocation);

Chris Broadfoot

unread,
Apr 18, 2011, 3:12:18 PM4/18/11
to google-map...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages