-1

I just did a Google search using: 'get current location' and I got this result:

enter image description here

It didn't ask me for my location, so I guess it's based on the IP location, or perhaps a cross reference of several information coming from my network (logged Google Accounts, Mobile devices, etc).

Is there a way to use Google Maps API, or any related Google service, to get this information, without having to ask the user for permission on the browser, to get their location?

Thank you

1
  • People voting negative this question: would you mind explaining what's wrong with it? Thank you
    – J Plana
    Feb 26, 2016 at 0:18

1 Answer 1

0

It's not a part of the Maps-API, but you may use the JSAPI(e.g. load the Maps-API via the JSAPI).

Although it isn't officially supported anymore, there still is(but must not be set) a property google.loader.ClientLocation

  google.load("maps", "3",{callback:function() {
        try{
          opts={
                center:new google.maps.LatLng( google.loader.ClientLocation.latitude,
                                               google.loader.ClientLocation.longitude),
                zoom:8
               };
        }catch(e){alert('no location available');
          opts={
                center: new google.maps.LatLng(0,0),
                zoom: 0
               };
        }
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            opts);
      }
      });
html,body,#map-canvas { height: 100%; margin: 0; padding: 0 }
<div id="map-canvas"></div>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>

Of course it's only as accurate as IP-based geolocation may be...not much

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.