【问题标题】:KML layer not showing upKML 图层未显示
【发布时间】:2016-01-15 15:31:27
【问题描述】:

我正在创建 KML 格式的矢量图层。我在下拉框中有源以避免 CORS,但是当我将它们加载到地图中时,它们没有任何功能。非常感谢您对这个问题的任何想法。

请看下面我是怎么做的。

var layers = [ 

wms_bmid_pipes = new ol.layer.Vector({
            source: new ol.source.Vector({
            url: 'https://dl.dropboxusercontent.com/s/ea4qzzuyk5i2mxt /geid_ws-bmid-pipes.kml?dl=0',
            format: new ol.format.KML() 
            })
        })
        ];

由于图层未显示在地图中,我运行下面的代码来检查它有多少功能(此代码来自开放图层网站)。事实证明,在控制台中我得到 "Count after change: 0" ,这意味着没有功能。

    wms_bmid_pipes.getSource().on('change', function(evt){
        var source = evt.target;
            if (source.getState() === 'ready') {
                var numFeatures = source.getFeatures().length; 
                console.log("Count after change: " + numFeatures);
            }
    });

关键是 wms_bmid_pipes 包含以下内容:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
    <LookAt>
        <longitude>-119.3597596329119</longitude>
        <latitude>49.89850519575446</latitude>
        <altitude>19983.5008834143</altitude>
        <heading>0.0</heading>
        <tilt>0.0</tilt>
        <range>16147.716881798802</range>
        <altitudeMode>clampToGround</altitudeMode>
    </LookAt>
    <NetworkLink>
        <name>bmid-pipes</name>
        <visibility>1</visibility>
        <open>1</open>
        <LookAt>
            <longitude>-119.3597596329119</longitude>
            <latitude>49.89850519575446</latitude>
            <altitude>19983.5008834143</altitude>
            <heading>0.0</heading>
            <tilt>0.0</tilt>
            <range>16147.716881798802</range>
            <altitudeMode>clampToGround</altitudeMode>
        </LookAt>
        <Url>
            <href>http://localhost:8080/geoserver/geid_ws/wms?service=wms&amp;request=GetMap&amp;version=1.1.1&amp;format=application/vnd.google-earth.kml+xml&amp;layers=geid_ws:bmid-pipes&amp;styles=line&amp;height=2048&amp;width=2048&amp;transparent=false&amp;srs=EPSG:4326&amp;format_options=AUTOFIT:true;KMATTR:true;KMPLACEMARK:false;KMSCORE:40;MODE:refresh;SUPEROVERLAY:false</href>
            <refreshInterval>0.0</refreshInterval>
            <viewRefreshMode>onStop</viewRefreshMode>
            <viewRefreshTime>1.0</viewRefreshTime>
            <viewBoundScale>1.0</viewBoundScale>
        </Url>
    </NetworkLink>
</Document>
</kml>

【问题讨论】:

    标签: kml


    【解决方案1】:

    KmlLayer 要求 KML 公开可用。 http://localhost:8080 不公开。

    <Url>
        <href>http://localhost:8080/geoserver/geid_ws/wms?service=wms&amp;request=GetMap&amp;version=1.1.1&amp;format=application/vnd.google-earth.kml+xml&amp;layers=geid_ws:bmid-pipes&amp;styles=line&amp;height=2048&amp;width=2048&amp;transparent=false&amp;srs=EPSG:4326&amp;format_options=AUTOFIT:true;KMATTR:true;KMPLACEMARK:false;KMSCORE:40;MODE:refresh;SUPEROVERLAY:false</href>
        <refreshInterval>0.0</refreshInterval>
        <viewRefreshMode>onStop</viewRefreshMode>
        <viewRefreshTime>1.0</viewRefreshTime>
        <viewBoundScale>1.0</viewBoundScale>
    </Url>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-06
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-01
      • 2013-06-27
      相关资源
      最近更新 更多