代码之家  ›  专栏  ›  技术社区  ›  CC12

google earth合并气球信息

  •  0
  • CC12  · 技术社区  · 7 年前

    我正在创建一个kml文件,每个placemark中都有图像引用。我想做两件事。首先,在用户缩放时合并位置标记。第二,能够将图像组合到同一个组合的地点标记中。我希望复制Panoramio placemarks和图片显示的相同类型的行为。

    我还没有找到执行这两种行为所需的代码示例。缩放时组合位置标记或合并引出序号内的信息。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Jim Simson qornanali    7 年前

    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>
    

    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()