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.

GoogleMaps03

GoogleMaps04

See here as well for the Maps API docs.

Advertisements

Cycling: MapMyRide and Google Earth

This was supposed to be a very short piece, but then it got way too interesting. This (Sunday) morning, Jan and I did an hour’s cycle ride out to Ellisfield. Thanks to MapMyRide, I know it was about 11 miles.

But because it is a very steep ride, I wanted to know the elevation. Tracing out the route (I just have the free subscription, btw), there was amusing stuff, like this “3D” video…

MapMyRide02

But nothing as far as I could see to give more stats (edit – so giving the post a test run, suddenly I see elevation stats. Fine). Then I saw this:

MapMyRide03

Drill into that, and you get this…

MapMyRide01

The combination of markup and Google Earth has to be promising. We download that..

MapMyRide04

Then download Google Earth

MapMyRide05

Then File/Open/(the kml file from above), after which you have this:

MapMyRide06

Right click anywhere on the red route and select Show Elevation Profile:

MapMyRide07

Clicking brings up this, with the focus on the start of the brutal climb. At least I made it today… previously I’ve had to get off and walk while Jan ambles past me… tortoise and hare style (hair style… never mind).

MapMyRide08