Google Maps - converting address to latitude & longitude - PHP backend? -


is possible convert (in php back-end):

<?php   $address = "street 1, city, country"; // normal address ?> 

to

<?php   $latlng = "10.0,20.0"; // latitude & lonitude ?> 

the code i'm using default one:

<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?v=3.exp&#038;sensor=false'></script>  <script>  function initialize() {   var mylatlng = new google.maps.latlng(10.0,20.0);   var mapoptions = {     zoom: 16,     center: mylatlng,     maptypeid: google.maps.maptypeid.roadmap   }   var map = new google.maps.map(document.getelementbyid('map'), mapoptions);    var marker = new google.maps.marker({       position: mylatlng,       map: map,       title: 'this caption'   }); }  google.maps.event.adddomlistener(window, 'load', initialize);   </script>  <div id="map"></div> 

i've been reading https://developers.google.com/maps/documentation/geocoding while i'm not experienced enough guess.

thanks.

this works me:

<?php   $address = urlencode($address);   $request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$address."&sensor=true";   $xml = simplexml_load_file($request_url) or die("url not loading");   $status = $xml->status;   if ($status=="ok") {       $lat = $xml->result->geometry->location->lat;       $lon = $xml->result->geometry->location->lng;       $latlng = "$lat,$lon";   } ?> 

references:


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -