Languages

Menu
Sites
Language
How can I get GPS location in my Web-based application?

Hello, everybody

Who know how to get GPS location in Web-based application, not in Native-based application?

Please help asap.

 

Regards,

Adal.

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

13 Replies
Lakshmi Grandhi
please go through the documentation for more information on location https://developer.tizen.org/documentation/using-location-based-services-tizen
Adal San
Thanks, Lakshmi
As I have determined W3C Geolocation specification hasn't been supported yet. "navigator.geolocation.getCurrentPosition" throws an error.
Lakshmi Grandhi
You have to set GPS setting to ON, then navigator.geolocation.getCurrentPosition return location latitude and longitude values.
Thanks a lot. GPS was turned on. Even though at starting of my app a confirm message appears and I'm confirming that the app might use location access, it didn't work. I checked the GPS settings and GPS was not for the app not activated. I think, It should happen automatically. This might be a bug?
Lakshmi Grandhi
i tried the below code on device, its working after enabling GPS in Settings Application. navigator.geolocation.getCurrentPosition(onPositionUpdate,errorHandle ) function onPositionUpdate(position) { console.log("inside ------") var lat = position.coords.latitude; var lng = position.coords.longitude; console.log("Current position: " + lat + " " + lng); } On which SDK are you trying ??
Adal San
Hi, Lakshmi. Did you test on the physical device ? I tried to get the current postion on WebSimulator and Emulator (SDK 2.0), but failed. - On WebSimulator says "getCurrentPosition function was not defined." - On Emulator, onSuccess callback is never called, onError callback is always called. Please check it WebSimulator and Emulator. I have no yet physical device. Thanks.
Lakshmi Grandhi
Hi Adal San, I have tested it on device, to work on emulator you need to inject any temporary lat, long to emulator using Event Injector tool, for more details go through below link https://developer.tizen.org/help/topic/org.tizen.gettingstarted/html/dev_env/providing_location_data.htm?resultof=%22%45%76%65%6e%74%22%20%22%65%76%65%6e%74%22%20%22%49%6e%6a%65%63%74%6f%72%22%20%22%69%6e%6a%65%63%74%6f%72%22%20 On emulator i found that injecting event is not working properly Thanks Lakshmi.
Imam Mohammad Bokhary

Anybody please tell me whats the problem of the below code for current location whereas it's working on Simulator and any browser but not working on device.

var map;
var myPosition;
var infowindow;

var directionsService;
var directionsDisplay;

window.onload=getLocation;

function getLocation() // get the current location
{
    if (navigator.geolocation)
    {
        navigator.geolocation.getCurrentPosition(initialize, showError);
    }
    else
    {
        alert("Geolocation is not supported by this browser.");
    }
}

function initialize(position)
{
      var pyrmont = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
      
      map = new google.maps.Map(document.getElementById('googleMap'), {
        center: pyrmont,
        zoom: 16,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      });

}

daniel kim

Hi,

As far as I know, your code can get the location data. I suggest you to check Privilege(http://tizen.org/privilege/location) and enable the Location menu in Setting of device.

 

This link has more descripton about google map in Tizen and has sample code as well.

    https://developer.tizen.org/documentation/articles/google-maps-on-tizen

 

I wish this will help you.

Imam Mohammad Bokhary

Yes, I've tried with geolocationtizen.zip code many times. But when I press "Acquiring your position" then it shown the popup menu loding and showing "Please wait..." in a long time and no output there.

I've enabled the location settings too.


 

 

AVSukhov

Hello,

first start gps may take a long time. And it's better to do it in an open area. =)

Imam Mohammad Bokhary

Thanks a lot. It's working..:)