标签: kml

将特定样式应用于KML中MultiGeometry中的线条

你好,我有一个多几何体,当你传递鼠标appair线时,怎样有一个像翻转的样式,我的问题是多几何中的差异线串有可能的不同颜色?

在下一个例子中,当你选择了一个样式时,我有地标Durham Tees Valley,但我希望这两行有不同的颜色.

谢谢

    <?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>UK &amp; Ireland, Flight Maps</name>
<open>1</open>
        <LookAt>
            <longitude>-3.478829007934099</longitude>
            <latitude>52.50255557278696</latitude>
            <altitude>0</altitude>
            <range>730703.2034581316</range>
            <tilt>53.03089122623036</tilt>
            <heading>30.72599120906411</heading>
        </LookAt>


  <Style id="test">
    <LineStyle>
      <color>ff235523</color>
      <width>0.5</width>
    </LineStyle>
  </Style>

<Style id="doc"><ListStyle><ItemIcon><state>open closed</state><href>http://maps.google.com/mapfiles/kml/shapes/airports.png</href></ItemIcon></ListStyle></Style>
<Style id="airportfolder"><ListStyle><ItemIcon><state>open closed</state><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></ItemIcon></ListStyle></Style>
<Style id="info"><ListStyle><listItemType>checkHideChildren</listItemType><ItemIcon><state>open closed</state><href>http://www.barnabu.co.uk/files/icons/info.png</href></ItemIcon></ListStyle></Style>
<Style id="sh_spider"><IconStyle><scale>1.2</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ff001111</color><scale>1.4</scale></LabelStyle><LineStyle><width>0.5</width><color>ffff111f</color></LineStyle></Style>
<Style id="sn_spider"><IconStyle><scale>0.7</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ffb5b5b5</color><scale>0.9</scale></LabelStyle><LineStyle><color>00ff11ff</color></LineStyle></Style>
<StyleMap id="spider"><Pair><key>normal</key><styleUrl>#sn_spider</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#sh_spider</styleUrl></Pair></StyleMap>


<Style id="2_sh_spider"><IconStyle><scale>1.2</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ff110011</color><scale>1.4</scale></LabelStyle><LineStyle><width>0.5</width><color>ff11111f</color></LineStyle></Style>
<Style id="2_sn_spider"><IconStyle><scale>0.7</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ff11ffb5</color><scale>0.9</scale></LabelStyle><LineStyle><color>001111ff</color></LineStyle></Style>
<StyleMap id="2_spider"><Pair><key>normal</key><styleUrl>#2_sn_spider</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#2_sh_spider</styleUrl></Pair></StyleMap>


<styleUrl>#doc</styleUrl>
<Folder><name>Airports</name>
<styleUrl>#airportfolder</styleUrl>


<Placemark><name>Durham Tees Valley</name><description></description>
<Snippet maxLines="0"></Snippet><styleUrl>#2_spider</styleUrl><MultiGeometry><LineString><altitudeMode>relativeToGround</altitudeMode><coordinates>-1.426979,54.5105876,0 -1.37505058232182,54.3588196840161,8130.76624025246 -1.32350445540046,54.2070296447423,15640.4403479026 -1.27233575193875,54.0552177670135,22453.9881416349 -1.22153968418068,53.90338433094,28503.3309041539 -1.17111154230159,53.7515296120054,33728.0256022233 -1.12104669283672,53.5996538811612,38075.8688134745 -1.07134057714712,53.4477574049198,41503.4183257466 -1.02198870992187,53.2958404454444,43976.4271973102 -0.972986677715595,53.1439032606379,45470.1859409886 -0.924330137520422,52.9919461042286,45969.769413186 -0.876014815371306,52.8399692258547,45470.1859409886 -0.828036504983954,52.6879728711457,43976.4271973102 -0.780391066424406,52.5359572818033,41503.4183257466 -0.733074424809449,52.3839226956791,38075.8688134745 -0.686082569037039,52.2318693468513,33728.0256022233 -0.639411550545936,52.0797974656991,28503.3309041538 -0.593057482103787,51.9277072789755,22453.9881416349 -0.547016536622892,51.7755990098789,15640.4403479026 -0.501284946002942,51.623472878122,8130.76624025247 …
Run Code Online (Sandbox Code Playgroud)

kml

6
推荐指数
2
解决办法
3040
查看次数

使用XSLT转换XML(以前称为KML)

嗨,我正在尝试使用w3schools XSLT Tryit编辑器转换KML文件(保存为XML文件),但我似乎无法让它工作.这是我的XML文件的片段:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
 <Document>
  <name>Bnsf RR cut</name>
  <open>1</open>
  <Style>
   <ListStyle>
    <ItemIcon>
     <href>kmzicon.png</href>
    </ItemIcon>
   </ListStyle>
  </Style>
  <Folder>
   <name>11/10/11 8:17:20 AM</name>
   <Placemark>
    <name>Track</name>
   </Placemark>
  </Folder>
  <Placemark>
   <name>Gray Mesa</name>
   <description><![CDATA[<img width="800" src="1.jpg"/>]]></description>
   <Point>
    <coordinates>-106.493097,34.446357,1692.000000</coordinates>
   </Point>
  </Placemark>
 </Document>
</kml>
Run Code Online (Sandbox Code Playgroud)

而我的XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
      <xsl:for-each select="Document/Placemark">
        <xsl:value-of select="name"/>
        <xsl:value-of select="description"/>
      </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

如果我删除XML代码中的kml标签它工作正常,但我宁愿尝试自动化这个,而不必从众多的XML中删除代码.我已经尝试将"kml"添加到我的XSLT代码"/ kml/Document/Placemark">但是这不起作用.谢谢!

我希望我的转换XML看起来像:

 <Document> 
  <Placemark>
   <name>Gray Mesa</name>
   <description><![CDATA[<img width="800" src="1.jpg"/>]]></description>
   <Point>
    <coordinates>-106.493097,34.446357,1692.000000</coordinates>
   </Point>
  </Placemark>
 </Document> …
Run Code Online (Sandbox Code Playgroud)

xml xslt kml

6
推荐指数
1
解决办法
3958
查看次数

Google Earth API中基于地区的网络链接

我有许多大型KML数据集,它们使用基于区域的网络链接层次结构来提供服务; 如KML参考中所述:

将Regions与NetworkLinks结合使用,可以创建指针层次结构,每个指针指向一个特定的子区域.如<viewRefreshMode>以下KML文件所示,具有onRegion选项,该选项指定仅在Region处于活动状态时加载Region数据.如果为嵌套区域提供多个详细级别,则仅当用户的视点触发下一个加载时才会加载更大量的数据.

这在Google地球中加载时效果很好.

我现在希望使用Google Earth插件在应用程序中加载这些内容. 我需要通过Google Earth API访问加载的内容 ; (即附加单击事件,更改样式)以将内容集成到应用程序中.

问题是,我没有找到任何关于网络链接的"有载"事件的参考.在我看来,这将起作用的方式是:

  • 通过API加载顶级网络链接,附加一个回调函数,该函数将在加载网络链接时调用.
  • 在回调函数中,解析网络链接返回的KML.对于区域层次结构中的中间级别,此KML将仅包含指向下一个区域级别的网络链接.通过API将它们加载到插件中,再次指定相同的回调函数,当加载它们时(即当它们的区域变得可见时)将调用它.
  • 最终,返回的KML将包含实际的"内容".在此阶段,我们在执行任何所需的修改(例如附加事件监听器,设置样式等)之后将实际内容(即地标)加载到插件中.

我认为javascript看起来像下面这样.
请注意:这只是一个草图,可能有助于理解我的问题.不是问为什么这段代码不起作用.

//create network link
var networkLink = ge.createNetworkLink("");
networkLink.setName("Regionated hierarchy root");

// create a Link object
//the network-links contained in the kml that will be returned in this file
//are region-based; they will only be loaded when the user zooms into the relevant
//region. 
var link = ge.createLink("");
link.setHref("http://foo.com/regionatedRoot.kml");

// attach the Link to the …
Run Code Online (Sandbox Code Playgroud)

kml google-earth-plugin

6
推荐指数
1
解决办法
912
查看次数

在kml文件中着色单轨

我试图让gx:track的线在轨道的不同部分有不同的颜色,具体取决于某些条件,但我无法找到方法为轨道的一部分着色.我正在使用C#生成kml文件.BTW我的gx:track的扩展数据.

我知道我可以将lineStyle应用到gx:track但是这只适用于整个轨道,但我希望沿轨道的线条有不同的颜色.

提前致谢.

特里

kml

6
推荐指数
1
解决办法
3779
查看次数

默认情况下,可以在Google地球中显示带有时间戳的所有地标吗?

我正在寻找使用Timestamp元素创建KML地标.这本身很容易做到,但我不喜欢Google Earth的行为只显示最初加载KML时的一小段时间.我希望它默认显示整个时间范围(以及所有地标).

有没有办法做到这一点?我没有在Google地球中看到任何设置,也没有看到KML文档中的任何设置.

我正在考虑的一个替代方案是基本上复制每个地标,并且在单独的文件夹中有1个设置有时间戳,1个没有.文件夹将使用单选按钮选择功能.如果可能的话,我想避免这种情况,因为KML可能有数千个地标,并且复制节点似乎是浪费.

以下是来自此源代码示例,如果您想要查看我所说的行为,那么KML会带有地标.

更新:我看到的时间滑块没有默认为包含的KML地标的完整范围的行为似乎是因为文件通过网络链接加载到本地文件.在这种情况下,我不确定如何控制时间滑块的行为.我可以让链接做一个"飞到查看刷新",它正确设置时间滑块,但我不想将相机移动到纬度/经度,因为我每4秒刷新一次.

timestamp kml google-earth

6
推荐指数
1
解决办法
5221
查看次数

自定义C++ Linux应用程序中的Google Earth

我正在探索在我为Linux编写的C++应用程序中使用Google Earth.该应用程序将以非常高的分辨率(大约6000 x 3000像素)运行.我对Google地球在高分辨率和Linux环境中的图形性能充满信心.我的问题是:将Google地球集成到我的Linux C++应用程序中的最佳方法是什么?我已经阅读了有关Google Earth COM API的信息(现在它已经过时了).将Google Earth集成到我的应用程序中的首选方法是什么?

整合的细节:我希望谷歌地球在"背景"中覆盖整个6000 x 3000分辨率,并带有一个与地球相互作用的小"控制盒"覆盖层.

谢谢你的回复!

KF

c++ google-maps kml google-earth google-earth-plugin

6
推荐指数
1
解决办法
1226
查看次数

在 simplekml 中显示本地图像

我正在尝试使用simplekml将一堆地理标记照片放入 KML 文件(实际上是 KMZ 文件)中,以便在 Google Earth 中查看。我已经获得了要显示的位置,但是当我尝试将图像放入“描述”中时,因此当我单击图像出现的位置时,它不起作用。只有一张空白图像。我正在尝试使用此处显示的 addfile() 命令来完成此操作。我的代码如下所示:

import os, simplekml

path = r'C:\Users\as\Desktop\testpics'                     
    
kml = simplekml.Kml()

for (dirpath, dirnames, filenames) in os.walk(path):
    for filename in filenames:
        fullpath = os.path.join(dirpath, filename)
        try:
            Lat, Long, Alt = GetLatLong(fullpath) #Didn't include this function, but it appears to work
        except:
            Lat, Long, Alt = (None, None, None)
        if Lat: #Only adds to kml if it has Lat value.
            x, y = (FormatLatLong(Lat), FormatLatLong(Long)) #puts into decimal coords …
Run Code Online (Sandbox Code Playgroud)

python maps kml google-earth simplekml

6
推荐指数
1
解决办法
3869
查看次数

PHP - 从'Point'形状生成kml

我正在使用PHPShapefile库来生成KML并将数据显示到谷歌地图,但是当涉及到"点"形状时它不起作用而不生成KML.这是Polygon形状的代码片段,帮助我为Point形状创建.

//this shape data i'm fetching from shapefile library.        
$shp_data = $record->getShpData();
if (isset($shp_data['parts'])) {
  $counter1 = 0;
  if ($shp_data['numparts']) {
    $polygon_array['polygon']['status'] = 'multi-polygon';
  } else {
    $polygon_array['polygon']['status'] = 'single-polygon';
  }

  $polygon_array['polygon']['total_polygon'] = $shp_data['numparts'];

  foreach ($shp_data['parts'] as $polygon) {
    foreach ($polygon as $points) {
      $counter = 0;
      $polygon_string = '';

      while ($counter < count($points)) {
        if ($counter == 0) {
          $polygon_string = $points[count($points) - 1]['x'] . ',';
          $polygon_string .= $points[$counter]['y'] . ' ' . $points[$counter]['x'] . ',';
        } …
Run Code Online (Sandbox Code Playgroud)

php google-maps kml shapefile

6
推荐指数
1
解决办法
354
查看次数

出现未定义的参考错误,但 nm 显示符号存在

我正在使用 libkml 构建一个大型应用程序。我从这里使用 libkml 的 cmake 端口: https: //github.com/rashadkm/libkml

即使该符号似乎已被引用和定义,我仍收到奇怪的未定义符号引用错误。

这是 make 命令:

/usr/bin/c++ -fPIC -Werror=return-type -Werror=return-type -Wall 
-Werror=parentheses -Werror=uninitialized -Werror=missing-braces 
-fPIC -O0 -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing 
-Wno-long-long -m64 -g -D_DEBUG --coverage -Wl,-Bsymbolic -Wl,--
no-undefined -shared -o GPS2KML.plb CMakeFiles/GPS2KML.dir
/gps.cpp.o CMakeFiles/GPS2KML.dir/kml.cpp.o CMakeFiles/GPS2KML.dir
/stdafx.cpp.o  /trunk/src/filter/GPS2KML/external/libkml/lib/cmake
/libkml/../../libkmlconvenience.so.1.3.1 /trunk/src/filter/GPS2KML
/external/libkml/lib/cmake/libkml/../../libkmlengine.so.1.3.1 
/trunk/src/filter/GPS2KML/external/libkml/lib/cmake/libkml/../..
/libkmldom.so.1.3.1 /trunk/src/filter/GPS2KML/external/libkml
/lib/cmake/libkml/../../libkmlbase.so.1.3.1 -lminizip -luriparser 
-lexpat
Run Code Online (Sandbox Code Playgroud)

制作输出:

CMakeFiles/GPS2KML.dir/kml.cpp.o: In function `cKML::~cKML()':
/trunk/src/filter/GPS2KML/src/kml.cpp:55: undefined reference to `*kmldom::SerializePretty(boost::intrusive_ptr<kmldom::Element> const&)*'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

现在,如果我这样做: daniyal@daniyal-Inspiron-5521:/$ nm --demangle --extern-only --define-only ../trunk/src/filter/GPS2KML/external/libkml/lib/libkmldom.so | …

c++ makefile cmake kml ld

6
推荐指数
1
解决办法
4034
查看次数

React-google-maps:如何创建一个可点击的 kml 地图来显示 kml 的元数据?

编辑:根据指南,有一个名为 getMetadata() 的方法。我如何使用它来返回道具?

描述:

使用 React-google-maps 包,我已经能够使用自己的 kml 文件加载 Google 地图。该 KML 文件包含多个形状,每个形状背后都有元数据。我想要的是,当用户单击这些形状之一时,他会在弹出窗口中看到形状背后的数据。

例子

假设我有一个 Google 地图,其中包含显示两个国家/地区的 kml 文件。用户将鼠标悬停在这些国家/地区之一上,会看到一个弹出窗口,显示他所在的国家/地区。他将鼠标悬停在第二个国家上空并得到相同的结果。当他单击该国家/地区的 KML 形状时,他会收到更多信息。

这需要我了解一些事情:

- 如何在 KML 形状上创建悬停效果以显示基于形状的数据
- 如何在 KML 形状上创建单击事件以显示基于形状的数据

但是,我无法理解如何使这个 KML 文件具有交互性。
这是我到目前为止所拥有的:

import React, { Component } from 'react';
import { withScriptjs, withGoogleMap, GoogleMap, Marker, KmlLayer } from "react-google-maps"

const MyMapComponent = withScriptjs(withGoogleMap((props) =>
  <GoogleMap
    defaultZoom={8}
    defaultCenter={{ lat: 50.5010789, lng: 4.4764595 }}
  >
    <KmlLayer 
        url='https://example.be/kmlfile.kml'
        options={{ preserveViewport : false}}
    />
    {props.isMarkerShown && <Marker position={{ lat: 50.5010789, …
Run Code Online (Sandbox Code Playgroud)

methods google-maps kml reactjs react-google-maps

6
推荐指数
1
解决办法
6501
查看次数