Reputation: 75
I've got a web application that uses google maps to display data from a database using a perl CGI to query the database. I decided to add an option to view data in google earth(standalone, not the plugin) instead of google maps.
How it works: User fills out a form, then clicks on a link that call some javascript that generates a url based on the form. Depending on the form input there may be 1 to 30 urls to open.
An example of a generated url:"http://wildlifedb-testing.buffalofieldcampaign.org//qs.pl?format=kml&startdate=2007-11-27&enddate=2007-12-4&species=bison&activity=¢erlat=44.714721¢erlon=-111.159067¢erdist=15&limit=2000"
I can take that url and add it as network link in GE and it opens just fine, but I can't figure out how to get it to open in GE directly from the browser. I tried setting window.location=url and that just causes the browser to download the file.
And yes, i've got the mime-type set right: "application/vnd.google-earth.kml+xml"
Upvotes: 0
Views: 738
Reputation: 21091
Can use the Google Earth API, to make a browser based implementation of Google Earth. http://code.google.com/apis/earth/
Or for a basic interface, pass the URL of a KML to this http://earth.google.com/kmlpreview/#url=http://www.example.com/path/to/file.kml
(just to be sure to urlencode your url - as you have special chars)
Upvotes: 0
Reputation: 75
So It ended up being to seperate problems, one with http headers, which i was able to solve by adding the following to the headers:
Content-Disposition: attachment; filename="sightings.kml"
The other problem was being able to open multiple files which i was able to solve by using window.open() instead of setting window.location
Upvotes: 0
Reputation: 180
GE won't open directly from the browser. You need to have the server generate a downloadable file containing the KML, that the user will open.
Check out how Wikipedia handles this. You go from a geo-located page (lat/lon in upper right) to GeoHack, which gives a bunch of mapping sites, including GE. Some sites can be opened directly because they are web apps. GE requests get sent KML as a download because it is a desktop app. Security.
Upvotes: 1