Embedding a Google map

Rail stations on a Google map.

Rail stations on a Google map.

I think I’ve fixed my issue with Google Maps (it looks like the default pins moved server) – hurrah!

As I’ve mentioned, I was a bit busy the last month or so, so it was only this weekend that I got the opportunity to update my All GB Rail Stations map with patronage data for 2014-15. The data has its own, small irregularities that need sorting first though.

I have a MySQL database with one table containing all the station details – location, post code, which company manages it – and the unique three-letter code. The ORR patronage data takes up a second table, but their station codes don’t always match the ones used by National Rail Enquires (and which you can download from www.gov.uk, somewhere). So I have to run through all 2,546 entries to correct Canada Water, South Woodham Ferrers and others, using an off-line, master Excel spreadsheet.

Then there are stations which are open but for which there is no patronage data. Some, like Barlaston or Wedgwood are open but you can’t catch a train from them as they don’t stop (and the platforms are fenced off). Others, like Manchester United FC, aren’t in regular use so don’t get counted either. It’s a faff, but not a great problem.

Then you export that data as a .csv file, replace the existing table with the new data, run a .php script to match the station details and patronage using the station code as a common field and create the .kml file, et voila. Job’s a good ‘un.

Where it starts to go wrong is in embedding it on this site. It’s a map, so you want it to take up as much as the screen real estate as possible, but there’s something odd with this template, whereby taking out the page title shifts things around so that the menu links – and in-map links – don’t work properly. So I shall have to step through the way the page is made and which .css calls are made when.

I’ve been using WordPress for over 10 years now, and writing web pages since 1994 so this shouldn’t be a problem… but it’s taken me two days so far. I know it’s not the obvious suspect – which helps, but not very much.

Update I have now fixed the issues, including for mobile devices. I’d be lying if I said I knew exactly what I’d done, as my editing didn’t work the first time. Nor the second, third or fourth times.

Update 2 Except, trying it again the morning after, Google doesn’t like the .kml map. Either it’s too large (2.4Mb) or they’re getting fed up of it hitting their servers.

Update 3 It was the file size – fixed by converting it into a .kmz file (297kb – much better)

Post navigation

Previous post
Lessons learned
Next post