Created
June 15, 2010 21:33
-
-
Save binarypie/439766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getLocation() { | |
// The static location. | |
if (typeof widget == 'undefined' || props.staticLocation == true) { | |
// we don't need to update our location as we are static | |
if (searchActive == false && | |
center_default.lat === props.defaultLatitude && | |
center_default.lng === props.defaultLongitude) { | |
return; | |
} | |
center_default.lat = props.defaultLatitude; | |
center_default.lng = props.defaultLongitude; | |
createPoint(); | |
return; | |
} | |
try { | |
so = device.getServiceObject("Service.Location", "ILocation"); | |
} | |
catch (e) { | |
alert("Can't find GPS service: " + e); | |
if (!hasTried) { | |
props.staticLocation = true; | |
hasTried = true; | |
getLocation(); | |
} | |
return; | |
} | |
try { | |
var updateoptions = new Object(); | |
updateoptions.PartialUpdates = false; | |
updateoptions.UpdateTimeOut = 120000000; | |
var criteria = new Object(); | |
// criteria.LocationInformationClass = "GenericLocationInfo"; | |
criteria.LocationInformationClass = "BasicLocationInformation"; | |
criteria.Updateoptions = updateoptions; | |
// var result = so.ILocation.Trace(criteria, callbackLocation); | |
var result = so.ILocation.GetLocation(criteria, callbackLocation); | |
var errCode = result.ErrorCode; | |
if (errCode) { | |
alert("Can't find current location."); | |
if (!hasTried) { | |
props.staticLocation = true; | |
hasTried = true; | |
getLocation(); | |
} | |
} | |
} | |
catch (e) { | |
alert("Can't find GPS signal: " + e); | |
if (!hasTried) { | |
props.staticLocation = true; | |
hasTried = true; | |
getLocation(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment