我试图将geojson文件(从AutoCAD文件转换为geojson)显示为第二层(第一层映射OSM)。
但是geojson内容会占据整个地图,而不是位于特定位置。
如何更改geojson文件中的坐标或如何减小geojson(第二层)的高度和宽度?请在下面的示例geojson文件中找到...
{
"type": "FeatureCollection",
"name": "entities",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [
{
"type": "Feature",
"properties": {
"Layer": "entities",
"SubClasses": "AcDbEntity:AcDbPolyline",
"EntityHandle": "1FFF0038"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
0,
0
],
[
0,
319.9694
],
[
361.2444,
319.9694
],
[
361.2444,
0
],
[
0,
0
]
]
}
},
{
"type": "Feature",
"properties": {
"Layer": "entities",
"SubClasses": "AcDbEntity:AcDbPolyline",
"EntityHandle": "1FFF011D"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
0,
252.0448
],
[
0,
319.9694
],
[
361.2444,
319.9278
],
[
361.2444,
142.5544
],
[
0,
142.5544
],
[
0,
197.4439
],
[
9.1842,
197.4439
],
[
9.1842,
151.7295
],
[
352.0603,
151.7295
],
[
352.0603,
310.7537
],
[
9.1842,
310.7932
],
[
9.1842,
252.0448
],
[
0,
252.0448
]
]
}
}
]
}
最后我通过取消投影CRS EPSG3857来获得解决方案,然后同一个geojson文件在Leaflet中正常工作。谢谢。
通过增加,
L.CRS.EPSG3857.unproject(point) // where point is coords.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句