1

I have a button that launches the google maps app on my device via an intent. I want to be able to pass it a php page that generates a KML file.

I have done this on a website before using the googlemaps api in JS - but it doesn't seem to work on Android.

My php file is as follows;

<?php
     echo '<kml xmlns="http://www.google.com/earth/kml/2">';
     echo '<Placemark>';
     echo '<name>Google Inc.</name>';
     echo '<description>1600 Amphitheatre Parkway, Mountain View, CA 94043</description>';
     echo '<Point>';
     echo '<coordinates>-122.0841430, 37.4219720, 0</coordinates>';
     echo '</Point>';
     echo '</Placemark>';
     echo '</kml>';
?>  

Launching with:

final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=http://website.com/kml_gen.php"));
startActivity(myIntent);

It launches maps, finds the file - but won't display it 'because it contains errors'.

Is this just not possible, or are there other ways to construct the intent that might work?

Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
Mark
  • 179
  • 1
  • 6
  • 15

1 Answers1

8

Try setting the mimetype according to spec: application/vnd.google-earth.kml+xml

Put this on the first line

header('Content-type: application/vnd.google-earth.kml+xml');
alexanderblom
  • 8,632
  • 6
  • 34
  • 40
  • that's done it. Perfect. Thanks. I suspected it was related to mimetypes, but wasn't sure how to change them in this case. – Mark Mar 18 '10 at 15:33