egeloen / ivory-google-map

Google Map API v3 integration for PHP 5.6+.
MIT License
325 stars 185 forks source link

Get location by Ip ? #244

Closed xorgxx closed 7 years ago

xorgxx commented 7 years ago

Hi i have just install your bundle and it since to all work well.

i have question : it's possible to get the geolocazation by IP ? if yes how.

Thank

egeloen commented 7 years ago

@xorgxx I'm not sure Google allows to geocode by IP... Can you point me the official doc about this feature?

xorgxx commented 7 years ago

ok i deed not realy see in PHP but it since to have in Js :

<!DOCTYPE html>
<html>
<body>

<p>Click the button to get your coordinates.</p>

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>

<script>
var x = document.getElementById("demo");

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.watchPosition(showPosition);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";}
    }

function showPosition(position) {
    x.innerHTML="Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude;
}
</script>

</body>
</html>

maybe possible to integrete in your bundle ? Thnak

egeloen commented 7 years ago

It is not related to Google Maps but related to your browser, so honestly, I'm not in favor of adding it to the bundle (and looking to the code, it's so simple that you can manage it yourself in your code very very easily).

xorgxx commented 7 years ago

it is very true!! Thank