JavaScript and Google Maps: GeoLocation

Useful blog here about GeoLocation in JavaScript. I struggled with getting permissions working in Chrome (but no such problem in Edge), so I’m hoping this will help me.

… No, doesn’t help on permissions in Chrome. But this does, and points out that the combination of a file-based URL and a request for GeoLocation permissions simply doesn’t work in Chrome – have to use a server.

So after a couple of hours, I have both GeoLocation and Mapping working, admittedly only in IE right now until I have time to move things to a server.

Example of the output from that – and to emphasise that for a file-based URL, you will only be able to get this to work in IE, and not Chrome or Edge:

GoogleMaps01 GoogleMaps02

Note that I have generalised the lat long for my own security – the values returned do get you to within a couple of metres of your actual location. See my code in PasteBin here and here and here for the code, and the function that rounds the lat long values.



See here as well for the Maps API docs.