mapbox引用json文件html,jquery - 如何使用GeoJSON将线串/折线添加到自定义MapBox模板中 - 堆栈内存溢出...

问题在于在此修改后的框架中添加了线串/折线。

例如,我无法使用以下格式通过线串GeoJSON数据添加新的地图图层:

L.map('map').

我可以使该线串与leafllet.js一起使用:

...但这使用了“ L”。 来自leaflet.js,并且在修改后的MapBox模板中不起作用。

L.geoJson(myLine1, {style: myStyle}).addTo(map);

问题是,MapBox修改后的商店定位器应用似乎没有实现相同的界面。

这是我当前的代码,试图添加具有线串的图层:

foursquare.lines = function() {

var lines = { 'type': 'FeatureCollection',

'features': []

};

lines.features.push({

type: 'Feature',

// id: venue.id,

geometry: {

type: 'LineString',

coordinates: [[

60.317769,

24.929009

],

[

24.9292486208828,

60.1681323558666

],

[

24.951764345169067,

60.168932342858554

],

[

24.93321418762207,

60.16911913731421

],

[

24.952929,

60.167312

],

[

24.944114685058594,

60.170111798603266

],

[

24.94499444961548,

60.171435300334004

]]

},

properties: {}

}); //push

//console.log(lines);

if (MM_map.lineLayer) {

MM_map.lineLayer.geojson(lines);

alert("hi");

} else {

MM_map.lineLayer = mmg().geojson(lines);

//alert("hello");

console.log(lines);

}

MM_map.addLayer(MM_map.lineLayer);

}; //foursquare.lines

图层被添加为空div,但是geojson和lines对象未得到处理且未显示。

当我运行console.log(lines)时,我正确地获取了所有geojson数据,只是没有使用此行添加它:

mmg().geojson(lines)

我真的很感谢这方面的帮助。 谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值