我正在创建一个kml文件,该文件在每个地标中都有图像引用。我想要做两件事。首先,在用户缩放时组合地标。其次,能够将图像组合成相同的组合地标。我希望复制与Panoramio地标和图片显示的相同类型的行为。
我还没有找到执行这些行为所需的代码示例。在缩放上组合地标或在气球内部组合信息。
答案 0 :(得分:0)
CC12,
您正在寻找的确切功能实际上并不存在,至少不是您想的那样。放大或缩小时,您看到的照片不会被合并或撕开,而是您所看到的是已分配给各个对象的区域的效果。正在进行合并,但是当照片上传到Google时会发生在后端。但是,你对这个问题的评论中的观点很好,当你从地图中复制一个对象时,KML没有附带它。要复制该功能,您必须自己添加区域:https://developers.google.com/kml/documentation/regions
要复制全景图层的风格方面,当然只需选择您选择的全景图像(在地图上),然后右键单击>复制然后将输出粘贴到您喜欢的文本编辑器中。以下是一个例子:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>KmlFile</name>
<Style id="pano_cluster1h">
<IconStyle>
<scale>0.7</scale>
<Icon>
<href>http://kh.google.com:80/flatfile?lf-0-icons/panoramio_cluster_n2.png</href>
<gx:w>32</gx:w>
<gx:h>32</gx:h>
</Icon>
</IconStyle>
<LabelStyle>
</LabelStyle>
<BalloonStyle>
<text>$[description]</text>
</BalloonStyle>
<LineStyle>
<color>ff000000</color>
<width>0</width>
<gx:labelVisibility>1</gx:labelVisibility>
</LineStyle>
<PolyStyle>
<color>ff000000</color>
</PolyStyle>
</Style>
<StyleMap id="1052802">
<Pair>
<key>normal</key>
<styleUrl>#pano_cluster1n</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#pano_cluster1h</styleUrl>
</Pair>
</StyleMap>
<Style id="pano_cluster1n">
<IconStyle>
<scale>0.5</scale>
<Icon>
<href>http://kh.google.com:80/flatfile?lf-0-icons/panoramio_cluster_n2.png</href>
<gx:w>32</gx:w>
<gx:h>32</gx:h>
</Icon>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
<BalloonStyle>
<text>$[description]</text>
</BalloonStyle>
<LineStyle>
<color>ff000000</color>
<width>0</width>
<gx:labelVisibility>1</gx:labelVisibility>
</LineStyle>
<PolyStyle>
<color>ff000000</color>
</PolyStyle>
</Style>
<Placemark>
<name>Zabriskie Point. Death Valley, California</name>
<description><![CDATA[<html><head><link rel="stylesheet" type="text/css"href="http://mw2.google.com/mw-earth-vectordb/panoramio_clusters/pcb.css"/><script type="text/javascript" src="http://mw2.google.com/mw-earth-vectordb/panoramio_clusters/pcb1.js"></script></head><body onload="loadPhotos(21262,'000145',8,36.420188,-116.812217,'n')"><div id="display-panel" style="position:absolute;border:none;height:578px;width:680px"></div><div id="hint">USA</div></body></html>]]></description>
<styleUrl>#1052802</styleUrl>
<Point>
<coordinates>-116.812217,36.420188,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
此外,以下是我写回来的一些Python脚本,以帮助设置GE中地标的区域。它现在设置为点和在Windows上运行,但它很容易适应任何事情。它的工作方式如下:您从GE复制地标,当您运行脚本时,它会向用户询问一个整数,该整数将设置您所在地区的消失点。脚本从剪贴板中提取KML,提取绳索,为kml生成正确的区域数据,并将结果放回剪贴板。然后,您可以将地标粘贴回地图上,并附上正确的区域数据。请记住,我只是写这个用于个人用途,所以代码有点乱,但它的效果很好(我几乎每天都使用它)。你走了:
import win32clipboard
import wx
import win32com.client, time
win32clipboard.OpenClipboard()
strClip = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
NakedRegion = "<Style><ListStyle><listItemType>checkHideChildren</listItemType><ItemIcon></ItemIcon></ListStyle></Style><Region><LatLonAltBox><north></north><south></south><east></east><west></west><minAltitude>0</minAltitude><maxAltitude>0</maxAltitude></LatLonAltBox><Lod><minLodPixels>10</minLodPixels><maxLodPixels>1024</maxLodPixels></Lod></Region>"
StartC = strClip.find("<coordinates>") + 13
EndC = strClip.find("</coordinates>")
StartIcon = strClip.find("<Icon>") + 6
EndIcon = strClip.find("</Icon>")
TheIcon = strClip[StartIcon:EndIcon]
StartName = strClip.find("<name>",600) + 6
EndName = strClip.find("</name>",600)
TheName = strClip[StartName:EndName]
TheCords = strClip[StartC:EndC]
TheLatLon = TheCords.split(',')
TheLat = float(TheLatLon[1])
TheLon = float(TheLatLon[0])
def ask(parent=None, message='Set Region to...'):
app = wx.App()
dlg = wx.TextEntryDialog(parent,message)
dlg.ShowModal()
result = dlg.GetValue()
dlg.Destroy()
app.MainLoop()
return result
n = ask(message = 'Integer...')
TheEnhancement = 0.00001 * (2**float(n))
TNorth = TheLat + TheEnhancement
TSouth = TheLat - TheEnhancement
TEast = TheLon + TheEnhancement
TWest = TheLon - TheEnhancement
NakedRegion = NakedRegion.replace("<north>", "<north>" + str(TNorth))
NakedRegion = NakedRegion.replace("<south>", "<south>" + str(TSouth))
NakedRegion = NakedRegion.replace("<east>", "<east>" + str(TEast))
NakedRegion = NakedRegion.replace("<west>", "<west>" + str(TWest))
strClip = strClip.replace("<name>KmlFile", "<name>" + str(TheName))
strClip = strClip.replace("<Placemark>", NakedRegion + "<Placemark>")
strClip = strClip.replace("<ItemIcon>", "<ItemIcon>" + str(TheIcon))
strClip = strClip.replace("<visibility>0</visibility>", "<visibility>1</visibility>" + str(TheIcon))
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(strClip)
win32clipboard.CloseClipboard()