Question

J'ai un bouton qui lance l'application Google Maps sur mon appareil via une intention. Je veux être en mesure de transmettre une page php qui génère un fichier KML.

Je l'ai fait sur un site Web avant d'utiliser l'api googlemaps à JS -. Mais il ne semble pas fonctionner sur Android

Mon fichier php est comme suit:

<?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>';
?>  

Lancement avec:

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

Il lance des cartes, trouve le fichier -. Mais ne l'affiche pas « car elle contient des erreurs »

Est-ce tout simplement pas possible, ou y at-il d'autres façons de construire l'intention qui pourrait fonctionner?

Était-ce utile?

La solution

Essayez de régler le type MIME selon les spécifications: application/vnd.google-earth.kml+xml

Mettre cela sur la première ligne

header('Content-type: application/vnd.google-earth.kml+xml');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top