获得映射到接受动态生成的KML文件? [英] getting maps to accept a dynamically generated KML file?

查看:201
本文介绍了获得映射到接受动态生成的KML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,通过一个意图启动设备上的谷歌地图应用程序。我希望能够通过这一个PHP页面,生成一个KML文件。

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.

我已经使用谷歌地图API中的JS之前在网站上的做到了这一点 - 但它似乎并没有工作在Android

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

我的PHP文件如下:

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

与启动:

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?

推荐答案

根据规范尝试将MIMETYPE:应用程序/ vnd.google-earth.kml + XML

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

将这个第一行

header('Content-type: application/vnd.google-earth.kml+xml');

这篇关于获得映射到接受动态生成的KML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆