Archive for the ‘Google Maps’ Category

Publish your KML via Google

Thursday, January 31st, 2008

Lately I have have been playing a lot with displaying KML files on various properties of Googles, and I thought it was about time I bookmarked the useful pages for my own reference – Firefox has them in the recent list now, but in 2 months time? Anyway in the end thought it would only take bit longer to collate them in a webpage, and make them dynamic links, so without further ado:

Useful links for publishing a KML via Google

Export all MyMaps to Google Earth

Monday, January 7th, 2008

====================

Update, 2nd August 2008

Suddenly it seems that the KML export from My Maps no longer pages like it used to, basically making this script redundant – which was always the intention!

So if your file has under 1000 features, then just use the link ‘View in Google Earth’ to get all the data. If you want the
actual data you can change the ‘output=nl’ to ‘output=kml’ to get the KML data rather than a Network Link to it.

====================

Oh dear, I think I should stay away from the Google Maps Group, following a post (about saving directions to MyMaps) on there a few days ago, realised the KML export is paginated, but there doesnt seem to be a way to get at the following pages directly. It flummoxed me for a while until guessed at the params to get the additional pages, success.

Then a post on there today, made me realise others are coming against this problem, so in traditional hackers** style, here is a little utility to create a multi page network link wrapper…

Export all MyMaps to KML

** follow the link for the definition I mean

Update: 18th Apr, we now download the first page of the map, 1) to get the number of items per page, it seems the link itself is no longer reliable, and 2) it means we can grab the title automatically :)
(note the download is discarded so I dont keep a copy of the data itself)

Export multi-destination (or dragged) route to Google Earth

Thursday, December 27th, 2007

Love keep adding destinations to your route, or even dragging the route to refine perfectly to your needs in the directions feature on Google Maps? But frustrated that this feature isn’t available in Google Earth?

… No, not implemented this feature for Earth (wouldn’t that be something!), but as a stop gap its a way to export your newly created directions on Maps, and open them in Google Earth! You get a freshly created folder containing each section as a separate route, ready for use as ‘one.

Multi Destination routing in KML for Google Earth

Serving Google Earth static content with Apache

Tuesday, November 6th, 2007

This could probably be classed as technical post (gosh!), and is probably only of interest if involved in hosting content to be displayed in Google Earth or Maps etc.

I’ve been meaning to write this up for a while, basically a set of tips for setting up Apache 2.X for hosting content for Google Earth. The same tips can probably be used for other webservers but won’t begin to look at the various ways it could be configured… Also these could easily be placed in httpd.conf, but using .htaccess as the example as thats probably easier, and not all hosting providers allow access to the file. Much of the stuff here originates from YSlow, but adopted for what I know about Google Earth.

These settings assume you not going to change the content much, so is good for serving up large static content, or the ‘chrome’ for a large layer. Regally updated content is likely up be output from a script anyway so that can setup its own headers, I’ve also done quite a bit of work on getting PHP to output good headers, so will post that in a follow up post.
First and foremost is setting up the MIME type, to ensure the Google Earth is launched when a user clicks a link, so these lines are added to the .htaccess file:

AddType application/vnd.google-earth.kml+xml kml
AddType application/vnd.google-earth.kmz kmz
AddType application/xml dae

Next is the Expires header, which tells a UserAgent how long it can cache the content, we set nice future dates, which mean in the main the content will stay cached for a while, potentially saving quite a bit of bandwidth.

ExpiresActive On
ExpiresByType application/vnd.google-earth.kml+xml "access plus 30 days"
ExpiresByType application/vnd.google-earth.kmz "access plus 30 days"
ExpiresByType application/xml "access plus 30 days"
ExpiresByType image/jpeg "access plus 180 days"

I’ve included JPG here, as it’s often used with GE, esp. how with the introduction of PhotoOverlay. The same idea can of course be extended if you use png files for example.
Now Apache out of the box supports sending Last-Modified headers, which means conditional GETs can be made later, which will only return 304 Not Modified. I’ve seen suggestion to turn off Last Modifed headers (if you have far future Expires as above) – but after testing, I would NOT recommend this.

Next is Etags, now YSlow recommends disabling these in most cases, and Apache useually comes with them on, and can easily be misconfigured, esp. on clustered hosting, so they need to be turned off. I’ve dithered on this one for a while, it seems silly to disable a feature that could potentially be useful, however the clincher here is that I don’t think GE will use them, and besides we can save a few bytes be not sending them in the first place.

FileETag none

I’ve no evidence if it helps, but if you have enabled on the fly GZip compression, then you might get a small boost by turning if off. As GE doesnt support HTTP-GZip compression, and KMZ and JPG are both well compressed. The only small benefit might be if you have a KML based loader, that might get downloaded by the browser in which case it can GZip’ed. So turn it off globally in this folder, but turn it back on for KML:

AddOutputFilterByType DEFLATE application/vnd.google-earth.kml+xml

As a final tip, the following allows you to upload a index.kml file and it will be served as the index for a directory, doesn’t help performance, but useful in a few cases,

DirectoryIndex index.kml index.html index.php

Get all of the above in one file ‘ere, use or don’t use at will :)

Google Earth 4.2 + FlashEarth equals…

Tuesday, August 28th, 2007

What if the current view in Google Earth was quickly viewable in other maps, such as those made accessible by FlashEarth? Well, now it is. As you move around the globe a little white arrow follows you around, simple click it to get an approximation of the current view in FlashEarth in a popup balloon.

Open in Google Earth

Total credit to Valery35, for the concept (including a screenshot) on the Google Earth Community. (and to all the people made all the bits that could be pieced together in this 15min hack)

8 out of 10 Travelling Salesmen use this map…

Thursday, July 19th, 2007

.. or should.

I just stumbled* across this rather neat Google Map “Mashup”: Optimap, it attempts to solve the classic ‘Travelling Salesman’ problem, that is find the shortest route to take in an arbitrary list of locations, reordering the locations as appropriate. Doing this manually is tedious at best, but you can miss some useful shortcuts, it’s also no easy task for a computer to solve, but with some clever maths (more on the authors blog!), its possible for a computer to have a good stab at it.

Anyway try it out:Optimap

Only thing missing is import/export functions :) – wonder in fact if the author could push to get this integrated into the real Google Maps engine, that would be so cool!

(* actually I read about it in the Google Maps API group)

The State of the Map…

Wednesday, July 18th, 2007

Over the weekend I attended OpenStreetMap‘s first conference “State of the Map“, all in all a very enjoyable time, great to to listen to all the talks, and also chat with various mappers, meet up with various people I’ve only met before in cyberspace.

Hopefully it will inspire me to actually contribute, esp as frequent two ‘holes’ in the current data…

An interesting little snippet from Ed Parsons talk, is this slide, which shows KML/GeoRSS publishing as indexed by Google, somehow I think I reconsise the British Isles hotspot; geograph, which publishes many KML feeds, (about 600k (the Superlayer, and also a file per photo), of which about 300k are reported to be indexed in Google’s main index, so show up well in ‘User Generated Content‘ in Google Maps!)

Everyone (nearly) – me third from left

Google will Geocode UK addresses and postcodes!

Friday, July 6th, 2007

Something we wondered if we would ever see, but it seems the Google Maps API geocoder will now Geocode UK Addresses and Postcodes (see update below). This is quite big news on many fronts, as traditionally UK geocoding is expensive, or where providers do geocoding its with restictions on use of the data commercially. But the API geocoder positivly encourages caching the geocodes for your locations (POIs), and in with particular Postcodes this has been a big no no. Can’t see any change in ToU’s in light of this, but we will see.

Has Google taken over the Royal Mail too now?

(the official announcement)

Update Nov ’07: … well it seems the postcodes was only a dream, and have now been withdrawn! Time will tell if this can be rectified. Ho hum…

Update Dec ’07: … the ToU have now been updated to clarify that the (http) geocoder is for the express use of ‘pre-caching’ geocodes for use on a Google Maps API map. (I’ve also clarified the above paragraph in regards to this). This also prevents some interesting uses, eg store locators that work before a map is shown (but an intereactive one with a map should be fine), which is a shame.

GoogleDevelDay: part 2

Thursday, May 31st, 2007

Have how been to the two ‘Geo’ sessions, nothing new to report I don’t think that can’t be got from gearthblog.com and the Google Maps API Group (where I had already heard of these), but anyway a quick round up of the main announcements (in no particular order)

  • Maps API – Can now do Directions :) – don’t yet know how flexible the API is tho, or if it even supports UK
  • Maps API – hint that the Geocoder might work (or soon) in the UK, but this could just be the questionee doesnt know yet.
  • Google Maps – Mapplets – porting a mashup to Google Maps
  • Google Earth – New KML 2.2 – as far as I gather its the KML spec only, the viewer is not released yet – but will check.
    • Support for Photo Placemarks – of particular interest to Geograph – tried something like this with models but never got it nice enough to release.
    • Add ‘atom’esque, link and author tags to Placemark
    • Update: just found the Camera tag, YAY!
    • http://code.google.com/apis/kml/documentation/kml_tags_beta1.html

    More as I find it out (I think I am missing some anyway…), I’ll also verify the facts and flesh out the features with links to more information.

    Update: forgot to mention Ed Parsons also used the Geograph Mapplet demo in his Keynote speech this morning. (see previous posts)

    @Google Developer Day

    Thursday, May 31st, 2007

    I think forgot to mention this before … just arrived in London for the Google Developer Day and waiting for it all to begin, hopefully will post a followup later one, once have something to report (other than might be a video about the event !)…

    oh… and jusw saw in the comments that the mapplet just posted was used in Google’s talk at Where2.0 ;)