Atlaslog
Atlaslog / OpenLayers / API reference / GeoJSONFormat
OpenLayers · API reference

GeoJSONFormat

Quick answer

GeoJSONFormat is ol.format.GeoJSON, a reader and writer converting between GeoJSON text and OpenLayers features. Set dataProjection to the source projection, EPSG:4326 by default, and featureProjection to the map projection so coordinates transform on read and write. Use readFeatures, writeFeatures or geometryName to control parsing and serialization.

Last verified 2026-11-03 · OpenLayers 10.3.1 · Cite this page
new ol.format.GeoJSON( options )
Key points
Example
var format = new ol.format.GeoJSON({ featureProjection: 'EPSG:3857' });

var features = format.readFeatures({
  type: 'FeatureCollection',
  features: [{
    type: 'Feature',
    properties: { name: '监测点 A', level: 3 },
    geometry: { type: 'Point', coordinates: [116.391263, 39.907359] }
  }]
});
console.log(features[0].getGeometry().getCoordinates());   // 米制坐标

var text = format.writeFeatures(features, {
  featureProjection: 'EPSG:3857',
  dataProjection: 'EPSG:4326'
});
console.log(text.slice(0, 60));
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). GeoJSONFormat. https://www.jingweizhi.com/en/openlayers/api/geojson-format.html (accessed 2026-11-03).