Jump to content


Photo

GetLocation Example

GeoLocation

  • Please log in to reply
No replies to this topic

#1 bahry

bahry

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 71 posts
  • LocationAmman

Posted 09 July 2018 - 10:52 AM

Hi to you all,

Anyone has an example on how to get the current location of the connected client?

I found the following script in "Stack overflow", but don't know how to return back the 'loc.lat' and 'loc.lng' to my code 

 

++++++++++++++++++++++++++++++

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
function initialize() {
var loc = {};
var geocoder = new google.maps.Geocoder();
if(google.loader.ClientLocation) {
loc.lat = google.loader.ClientLocation.latitude;
loc.lng = google.loader.ClientLocation.longitude;
var latlng = new google.maps.LatLng(loc.lat, loc.lng);
geocoder.geocode({'latLng': latlng}, function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
alert(results[0]['formatted_address']);
};
});
}
}
google.load("maps", "3.x", {other_params: "sensor=false", callback:initialize});
</script>

++++++++++++++++++++++++++++++

 

Regards

 

 


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users