首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >从geojson绘制openlayers多段线

从geojson绘制openlayers多段线
EN

Stack Overflow用户
提问于 2018-06-08 23:51:18
回答 1查看 1.1K关注 0票数 0

我正在试着定制这个例子:

http://openlayers.org/en/latest/examples/feature-move-animation.html

代码语言:javascript
复制
var strGeoJson = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[25.094146728515625,57.51877294160811],[25.135345458984375,57.55857562213471],[25.11749267578125,57.583614274541404],[25.022735595703125,57.58508660014084],[25.017242431640625,57.633639928856965],[25.11199951171875,57.655688188735766],[25.081787109374996,57.69240553526455],[24.97055053710937,57.68873547372526]]}}]}';

var route =  (
    new ol.format.Polyline({
        factor: 1e6
    }).readFeatures(
        strGeoJson,
        {
            dataProjection: 'EPSG:4326',
            featureProjection: 'EPSG:3857'
        }
    )
);


var routeFeature = new ol.Feature({
    type: 'route',
    geometry: route
});

vectorLayerSource = new ol.source.Vector({
    features: [routeFeature]
});

但一直都是:

代码语言:javascript
复制
ol.js?20180608153258:47 Uncaught TypeError: a.addEventListener is not a function
    at y (ol.js?20180608153258:47)
    at Hk.k.Oe (ol.js?20180608153258:302)
    at Hk.b (ol.js?20180608153258:46)
    at Hk.Sc.b (ol.js?20180608153258:49)
    at Yc (ol.js?20180608153258:51)
    at Hk.k.set (ol.js?20180608153258:51)
    at Hk.k.H (ol.js?20180608153258:52)
    at new Hk (ol.js?20180608153258:301)
    at HTMLDocument.<anonymous> (history-map:1372)
    at i (jquery-2.2.3.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-2.2.3.min.js:2)
    at Function.ready (jquery-2.2.3.min.js:2)
    at HTMLDocument.J (jquery-2.2.3.min.js:2)

有人能说出问题出在哪里吗?如何从geojson.绘制一条线

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50764281

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档