Languages

Menu
Sites
Language
Can't get current location

Hi,

I have tried all the ways I could get my hands on for getting the current location but I am unable to make it work. I am using a development purpose device for testing this. I want to get the current location (which is working fine in web simulator application) and feed it to some function which draws the route on a google map. In the target device, if I feed two locations( i.e. fromLocation and  toLocation) manually , it works fine but as soon as I give 'fromLocation' as the current location, nothing is shown in the map div. The code is as follows :

//inside some function
if(navigator.geolocation) {
    	console.log("inside geolocation function");
	    navigator.geolocation.getCurrentPosition(function(position) {	
	      var pos = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);//It gets stuck at this statement
	      console.log(pos);
	      calculateRoute(pos,destination);
	      });
	      }
	else console.log("does not support geolocation");
	
    
//calculateRoute function
function calculateRoute(from, to) {
      // Center initialized to New Delhi, India
      var myOptions = {
        zoom: 10,
        center: new google.maps.LatLng(28.6, 77.2),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        streetViewControl : false
      };
      // Draw the map
      var mapObject = new google.maps.Map(document.getElementById("map"), myOptions);

      var directionsService = new google.maps.DirectionsService();
      
      var directionsRequest = {
        origin: from,
        destination: to,
        travelMode: google.maps.DirectionsTravelMode.DRIVING,
        unitSystem: google.maps.UnitSystem.METRIC
      };
      directionsService.route(
        directionsRequest,
        function(response, status)
        {
          if (status == google.maps.DirectionsStatus.OK)
          {
            new google.maps.DirectionsRenderer({
              map: mapObject,
              directions: response
            });
          }
          
        }
      );
    }

Here, if instead of

calculateRoute(pos,destination);

I give something like -

calculateRoute("Bangalore","Delhi");

then it works. So, the problem lies with finding the current location. I have given the location priveleges also in the config file.

Please help

Thanks.
 

Responses

10 Replies
Marco Buettner

Whats your target device?

Siddharth Bhardwaj

Its a Tizen development device based on S3 model.

Vikram

Hello,

I think that this is known issue of RD-PQ. please refer to this link.

    https://developer.tizen.org/forums/web-application-development/wrong-map-coordinates

Marco Buettner

The RD-PQ has hardcoded GPS coordinates, use Event Injector
 

AVSukhov

Hello,

You can test your app on Emulator using Event Injector:

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.devtools/html/common_tools/event_injec.htm

Siddharth Bhardwaj

Is there a way I can test this on the actual Tizen Z1 device? I have the market version of Samsung Z1.

Vikram

Yes.

First, to enable the usb debugging on Z1, refer this link http://www.tizenexperts.com/2015/01/developer-enable-developer-usb-debugging-mode-tizen-samsung-z1-sm-z130hds/

Second, install "Tizen Extension SDK for certificate" to your PC (with your tizen SDK). You can download the extention at here http://developer.samsung.com/samsung-z

Then, follow below process, you can search “Certificates” on IDE help doc.

  •           Run “Register and Register a Certificate” menu on IDE and generate a new certificate file and register it to the IDE. First, you need to generate new CSR file and request your author certificate (crt file) using generated CSR file on the same menu. Then, you need to get the DUID of your device in the connection explorer and request a device profile. When you request your author certificate and device profile, you need your account of Samsung developer site. After that, you will receive author.crt and device-profile.xml via your email. You can register these files on the “Request and Register a Certificate” menu on IDE.
  •           Then, please right-click a device which displayed in the connection explorer and select the “Permit to install applications” to transfer device-profile.xml to /home/developer folder of device.

** DUID is looks like following :  1.0#YiOG+Abg+etSr5YITrxkLeZVIoo=

 

Siddharth Bhardwaj

Thanks, I am able to test the app on the Z1 device. But the map is not working even on this device. Someone who has used the current location in the google maps, please help.

AVSukhov

Hello,

About using Google maps in Tizen:

 

https://developer.tizen.org/documentation/articles/google-maps-on-tizen?langredirect=1

 

Siddharth Bhardwaj

Hi,

I have referred to this link only. I have also posted the code and my problem, if you or someone can please check the code above for any mistakes(or any addition or suggestion). I am unable to figure out what is the problem.