Hello
I have a problem in mysql data recovery
I'm following php code: connecting to the database and recovers the two variables longitude and latitude,
<?php
$sql="Select * from localiser";
$sql_result=mysql_query($sql,$connection1) or exit("Sql Error".mysql_error());
$sql_num=mysql_num_rows($sql_result);
$longit=$sql_row["Longitude"];
$latit=$sql_row["Latitude"];
I found the code that gives me my current coordinate location on map and to display,
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>;
<script type="text/javascript">
function getCoordPosition(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var altitude = position.coords.altitude;
document.getElementById('geolocation').innerHTML = 'latitude : ' + latitude + '<br />' + 'longitude : ' + longitude + '<br />' + 'altitude : ' + altitude + '<br />';
});
}
}
function showGoogleMap(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
// also monitor position as it changes
navigator.geolocation.watchPosition(showPosition);
} else {
console.log("no geolocation support" );
}
function showPosition(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var options = { zoom: 13, center: new google.maps.LatLng(lat, lng), mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById("contentMap" ), options);
var marker = new google.maps.Marker({ position: new google.maps.LatLng(lat, lng) });
marker.setMap(map);
}
}
</script>
</head>
<body>
<div id="coords">
<h1>Les coordonnées</h1>
<button onClick="getCoordPosition();">Obtenir les coordonnées</button>
<div id="geolocation"></div>
<p>
<a href="javascript:window.close();">Retour à l'article</a>
</p>
</div>
<div id="map">
<h1>Exemple avec Google Map</h1>
<button id="see_position" onClick="showGoogleMap();">Position sur Google Map</button>
<div id="contentMap" style="height: 280px"></div>
<p>
<a href="javascript:window.close();">Retour à l'article</a>
</p>
</div>
</body>
I wanted to change the two variables that (var latitude = position.coords.latitude;
var longitude = position.coords.longitude
I "ve tried var latitude = <? php echo $ lat;?>
var longitude = <? php echo $ longit;?> but it does not work, how?