Archive for the ‘Google Maps’ Category

Google Earth in the Browser

Wednesday, May 28th, 2008

Google has just announced a new Google Earth API - which allows embedding and fully functional Google Earth in just about any webpage. Even is easily intergratable with Google Maps API mashups - with very little extra code. (takes a number of seconds for that news to sink in!)

Be sure to checkout the samples, (particularly the milktruck demo!), I’ve also started trying it out with a few demos of my own

…Windows only btw…

Expect A LOT MORE from this very flexible looking API - the JS interface can quickly interact with objects (API is based around KML) and gets pretty good control of interface options.

Update: mentioned on gearthblog.com which is a good introduction about what this is and what its not!

Update2: and to show it can basically be added to a ‘real world’ Gmaps mashup, in a few lines of code, see here

HowTo: Copy/Move features between My Maps (GoogleMaps)

Friday, May 23rd, 2008

Google Maps doesn’t include a method to copy/move features between maps, however as you can import and export features using KML files you can easily use these features to archive the job.

I’ve moved the meat of this post to a Thread on the Google Maps Group - better for Google to be hosting it.

Howto: Alternative to paging on MyMaps (GoogleMaps)

Friday, May 23rd, 2008

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

Update, 2nd August 2008

Suddenly it seems that the KML export from My Maps no longer pages like it used to, so this process is now a lot quicker!

Just use the link ‘View in Google Earth’, and paste it directly in the search box to get access to the geographical culling method. No more going and creating a kml file or any sillyness.

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

Introduction

In order to keep the map working at reasonable speed Google Maps needs to limit the available features visible at once, quite simply the more features shown the slower the map gets.

For MyMaps the features are split into pages, so that a reasonable amount of data is shown on one page - effectivly enough that will work at a reasonable speed. This normally results in between 60-200 features at once, but sometimes that is not enough.

However Google Maps uses a different limited method when displaying KML files, a regional geographical culling based method. A certain number of features are shown, to give a reasonable overview, but then as you zoom in more features become visible. This often results in more results being visible, but importantly doesn’t impose the arbitrary pages, so its often more friendly on the user, as can just zoom in on an area rather than flick though pages to find their area.

I’ve moved the meat of this post to a thread on the Google Maps Group - let Google host it!

Howto: Save Directions to a MyMap (GoogleMaps)

Friday, May 23rd, 2008

Google Maps doesn’t include a method to save ‘Driving Directions’ easily into MyMaps. Fortunately they do include KML import/export for most features, so can export the route as KML then reimport it into a My Map.

I’ve moved the meat of this post to a Thread on the Google Maps Group, better for Google to be hosting it :)

(Google) GeoWeb Search API

Wednesday, May 14th, 2008

I dont know when it happened, but the API to search Googles GeoIndex seems to have gone live. The documentation is here (http method) and here (javascript). I actully found this via the recently announced Google Maps API for Flash, which is also good.

/me wanders off to play (but dont have much time at the moment :( )

but before I go, I note that the api doesn’t appear to offer KML output :p

… unless of course the actual GeoSearch API is something bigger!

update: try it out:

http://www.nearby.org.uk/google/geoweb_explorer.php

Not much to look at, but does show the json in a slightly easier to read format. Of course need to make a Maps API based map to try it out, but not tonight… (but did get as far as KML output - with source code!)

update2: Its been formally announced! (also if you find the ‘blended’ doesnt return results you expect, see this thread

(static) Google Maps in Google Earth…

Thursday, February 21st, 2008

Now that Google have just announced a brand spanking new NON JS Maps API, to be able to display maps with a simple img tag, similar to the Chart API. Well I thought it would be fun to re-purpose the
FlashEarth code to create a network link to display Google Maps in a popup balloon on Google Earth. Not totally sure the utility, but sure is fun (until the novelty wears off!)

Open in Google Earth

Hopefully needless to say the map inside the balloon is static and non draggable.

Update to clarify: You get to draw 1,000 maps daily, which is probably plenty, but go over that and the maps will stop working for you.

Update: as alluded to in the official post, you can use the static API to load a quick map, while the rest of the page loads, then at the last minute change it into a dynamic map. A series of demos showing various ways of lazy loading!

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 :)