PHP为地图上的多个地标动态创建KML [英] PHP Dynamically creating KML for multiple placemarks on map

查看:91
本文介绍了PHP为地图上的多个地标动态创建KML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前正在努力使用PHP并从中创建KML.我正在使用last.fm API(geoGetevents)从位置"获取事件(例如,用户搜索曼彻斯特),然后(使用KML,因为我觉得它比JS更舒适)在地图上绘制这些事件.

Currently struggling with PHP and creating KML from it. I'm using the last.fm API (geoGetevents) to grab events from 'location' (for example, user searches for Manchester) and then (using KML - as I feel more comfortable with it than JS) plot these on a map.

我发现从Feed中链接到Google地图时,收到无效的KML/KMZ错误.话虽如此,我知道为什么.所有内容都包含在一个文件中-包括PHP生成的KML.

I'm finding that I get invalid KML/KMZ errors when linking to a google map from my feed. Having said that, I know why.. Everything is contained in one file - including the KML that PHP generates.

因此,使用GET变量,URL为 http://example.net/dmp/search.php?city = bristol

So with GET variable, the URL is http://example.net/dmp/search.php?city=bristol

Google地图忽略了?"之后的其余URL. -有什么方法可以将动态生成的KML发送到Google地图?也许创建一个单独的KML文件?

Google Maps is ignoring the rest of the URL after the '?' - is there any way I can send the dynamically generated KML to google maps? Maybe creating a separate KML file?

<kml xmlns="http://www.opengis.net/kml/2.2"> <!-- Sets KML header --> 
<Folder> 
<name>Gigs</name> 
      <Placemark><name>As I Lay Dying</name><description> etc

这是PHP创建的当前KML.

That is the current KML that is created by the PHP.

希望您能提供帮助,并在此先谢谢您

Hope you can help, and thank you in advance

推荐答案

我想我有你的答案了吗? 这将允许气泡出现在带有html的点击图标上方

i think i have your answer have you put the link inside a Cdata inside your description this will allow a bubble to appear above the click icon with html in it

一个很好的例子是marinetraffic.com

good example is a marinetraffic.com

发送动态创建的kml.

sending dynamically created kml.

将此添加到您的Apache mime.types application/vnd.google-earth.kml + xml kml

add this to your Apache mime.types application/vnd.google-earth.kml+xml kml

放置此内容 标头(内容类型:application/vnd.google-earth.kml + xml");

at the top of the page that outputs the file put this Header('Content-type: application/vnd.google-earth.kml+xml');

雅达雅达

ps,您可以在 http://code中找到有关cdata的大量信息. google.com/apis/kml/documentation/kml_tut.html

然后,您需要创建一个网络链接文件,该文件的kml文件会告诉Google Maps Ware查找服务器

then you need to create a network link file its a kml file that tells google maps ware to look for your server

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2">
      <Folder>
        <name>Network Links</name>
        <visibility>0</visibility>
        <open>0</open>
        <description>Network link example 1</description>
        <NetworkLink>
          <name>Random Placemark</name>
          <visibility>0</visibility>
          <open>0</open>
          <description>A simple server-side script that generates a new random
            placemark on each call</description>
          <refreshVisibility>0</refreshVisibility>
          <flyToView>0</flyToView>
          <Link>
<refreshInterval>600.0</refreshInterval>

<refreshMode>onInterval</refreshMode>
            <href>http://yourserver.com/cgi-bin/randomPlacemark.py</href>
          </Link>
        </NetworkLink>
      </Folder>
    </kml>

我添加了刷新间隔,因为这将使其自动更新

i added Refresh interval as this will make it auto update

希望这可以帮助您解决问题,因为您比我知道更多的php,您介意看看我的问题吧!哈哈乔普这有帮助

hope this helps chap since you know a alot more php than i do would you mind having a look at my problem ! haha jope this helps

这篇关于PHP为地图上的多个地标动态创建KML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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