google maps - PHP - Get Latitude & Longitude from an address -


I have used autocomplete of geocode, but when I am selecting from the drop down, it gives me latitude and I am going to know when latitude and long term are empty, then I should get latitude and longitude from the postal address

Assume that you have hidden values ​​for latitude and long map halts & amp; mapLong and input field namespace, you can check the following

  & lt; Html & gt; & Lt; Form & gt; & Lt; Input type = "hidden" name = "maplate" & gt; & Lt; Input type = "hidden" name = "map" & gt; & Lt; Input type = "text" name = "location" & gt; & Lt; Input type = "submit" name = "submit" value = "submit" & gt; & Lt; / Form & gt; & Lt; / Html & gt; Extact ($ _post); If you lie long ($ mapLat == '' & amp; $ mapLong == '') {// Google $ latlong = get_lat_long ($ location); // $ below map = explosion (',', $ latlong) given as a function with name "get_lat_long"; $ MapLat = $ map [0]; $ Map Long = $ Map [1]; } // get_lat_long ($ address) {$ address = str_replace ("", "+", $ address) to get the function's address; $ Json = file_get_contents ("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®region=$region"); $ Json = json_decode ($ json); $ Lat = $ json- & gt; {'Result'} [0] - & gt; {'Geometry'} - & gt; {'Location'} - & gt; {'Lat'}; $ Tall = $ json- & gt; {'Result'} [0] - & gt; {'Geometry'} - & gt; {'Location'} - & gt; {'Lng'}; Return $ renewable. ','. $ Long; }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -