我是OpenLayers的新手。我正在制作一张网络地图,但我不知道为什么geojson图层没有显示,只显示了基本地图。我的代码如下:
<!DOCTYPE html>< HTML> < …
您需要包含自定义投影(NAD83 / UTM区域17N(EPSG:26917))
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js"></script> <script src="https://epsg.io/26917.js"></script> <script> ol.proj.proj4.register(proj4); var dataProjection = ol.proj.get('EPSG:26917'); var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }), new ol.layer.Vector({ title: 'added Layer', source: new ol.source.Vector({ url: 'FLOOD_PLAIN.json.txt', format: new ol.format.GeoJSON({ dataProjection: dataProjection, featureProjection: 'EPSG:3857' }) }) }), new ol.layer.Vector({ title: 'added Layer', source: new ol.source.Vector({ url: 'BUILDING_FOOTPRINT.json.txt', format: new ol.format.GeoJSON({ dataProjection: dataProjection, featureProjection: 'EPSG:3857' }) }) })], view: new ol.View({ center: ol.proj.fromLonLat([-80.981948,43.370172]), zoom: 14 }) });
概念证明