php get latitude from address without api key

php get latitude from address without api key



I have function that get address and return latitude and longitude.



The problem is that after a while i'm getting 0.00000 for both lat & lng. I guess that i need to add "&key=API_KEY" to the url, and if i got it right it's cost money.



Is there any other way to get address lat & lng ?


function get_address_lat_lng ($address)


$prepAddr = str_replace(' ','+',$address);

$geocode=file_get_contents('https://maps.google.com/maps/api/geocode/json?address='.urlencode($prepAddr).'&sensor=false');

$output= json_decode($geocode);

$lat = $output->results[0]->geometry->location->lat;
$lng = $output->results[0]->geometry->location->lng;

return (array('lat' => $lat, 'lng' => $lng) );





for reistered user (for obtain google key) google maps new policies .. give a free amount each month for some operation check google maps site for this ..
– scaisEdge
Sep 2 at 11:40





@scaisEdge - hi. so why do i get 0.0000 for lat & lng? I don't have lot of traffic...
– Roi
Sep 2 at 11:56





you have not apikey .. so you have not result .. you must have a valid apikey
– scaisEdge
Sep 2 at 11:57




1 Answer
1


function ipLookUp ()
$.ajax('http://ip-api.com/json')
.then(
function success(response)
console.log('User's Location Data is ', response);
console.log('User's Country ', response.country);
,

function fail(data, status)
console.log('Request failed. Returned status of ', status);

);

ipLookUp()



Check your console logs on browsers but this is based on IP of client.





I think you confuse with the topic....
– Roi
Sep 2 at 11:55





thats right , from address !! i will edit it soon
– Ahmed Shahin
Sep 2 at 11:58





@AhmedShahin : while you are rethinking your answer, consider that your php looks a lot like js.
– YvesLeBorg
Sep 2 at 12:07





you can write javascript and call it in php ... do you want me to make live example ?
– Ahmed Shahin
Sep 2 at 12:08





@AhmedShahin - Hi there. Your script return latitude and longitude by user location. I need it by address...
– Roi
Sep 2 at 15:17



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ