语言

Menu
Sites
Language
wrong Map coordinates

Hello,

I am trying to test this example from the Tizen CookBook:

https://www.packtpub.com/books/content/using-sensors

The example works fine, but it gives me always a wrong coordinatesusing this method:

function showLocation(location) {
    console.log('latitude: ' + location.coords.latitude + '  longitude: ' + location.coords.longitude);
}

 

what's wrong in your opinion?

Thank you in advance.

响应

4 回复
Leon Anavi

Hi, function showLocation just prints the coordinates in the console. Could you please share more details? Are you testing on device or an emulator?

karray gargouri

Hi,

I am using the RD-PQ Tizen Test Device (version 2.2.1).

Here is my code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="A single-page template generated by Tizen Web IDE"/>

    <title>Tizen Web IDE - Tizen - jQuery Mobile - Single-Page</title>

    <link rel="stylesheet" href="./css/jquery.mobile-1.3.2.css"/>
    <script type="text/javascript" src="./js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="./js/jquery.mobile-1.3.2.js"></script>
    <script type="text/javascript" src="./js/main.js"></script>
    <link rel="stylesheet" href="./css/style.css" />
    
    <style type="text/css">
#map-canvas { width: 320px; height: 425px; }
</style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCvarq2LhJLMMPb7m0sGJlk0PYKBwye9UQ&sensor=false"></script>

<script type="text/javascript">

function showError(err) {
    console.log('Error ' + err.code + ': ' + err.message);
	}

function showLocation(location) {
	console.log('latitude: ' + location.coords.latitude + '  longitude: ' + location.coords.longitude);

	var mapOptions = {
			   center: new google.maps.LatLng(location.coords.latitude, location.coords.longitude),
			   zoom: 14
			};
			var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
			var marker = new google.maps.Marker({
			   position: new google.maps.LatLng(location.coords.latitude, location.coords.longitude),
			   map: map
			});
	}

function retrieveLocation() {
	if (navigator.geolocation) {
	   navigator.geolocation.getCurrentPosition(showLocation, showError);
	}
	}

function initialize() {
	retrieveLocation();
	/*var mapOptions = {
   center: new google.maps.LatLng(location.coords.latitude, location.coords.longitude),
   zoom: 14
};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var marker = new google.maps.Marker({
   position: new google.maps.LatLng(location.coords.latitude, location.coords.longitude),
   map: map
});
}*/
}
</script>
    
</head>

<body onload="retrieveLocation()">
<div id="map-canvas"></div>
</body>
</html>

 

Thanks!

Leon Anavi

There is a known issue with the location on RD-PQ. Please have a look at this thread for more information: http://developer.tizen.org/comment/13781

AVSukhov

Hello,

Yes, this is known issue.

For testing you can use emulator with Event Injector.