Good day.

There are type coordinates:
Latitude: 55.633671
Longitude: 37.769749

A dotted map is drawn, but geojson uses a different coordinate system.

var geojsonObject = { 'type': 'FeatureCollection', 'features': [{ 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [4172850.2481443416,7506727.67383059] } }] } //----------------- карта ---------------------- var vectorSource = new ol.source.Vector({ features: (new ol.format.GeoJSON()).readFeatures(geojsonObject) }); var vectorLayer = new ol.layer.Vector({ source: vectorSource }); var rasterLayer = new ol.layer.Tile({ source: new ol.source.OSM() }); var map = new ol.Map({ layers: [rasterLayer, vectorLayer], target: document.getElementById('map'), view: new ol.View({ center: ol.proj.fromLonLat([37.61, 55.75]), zoom: 2 }) }); 

When I try to substitute my coordinates, he puts the label at [0, 0], how to make him use my coordinates?

  • If you are given an exhaustive answer, mark it as correct (tick the selected answer). - Mihanik71

2 answers 2

The coordinate system is the same. In the Google example, data is drawn according to standard lat, lng. GeoJson file example - refers to the same Google example.

Connecting the GeoJson file:

 var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { zoom: 4, center: {lat: -28, lng: 137} }); // NOTE: This uses cross-domain XHR, and may not work on older browsers. map.data.loadGeoJson('https://storage.googleapis.com/maps-devrel/google.json'); } 

Example JSON file for drawing a polyline:

 { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "letter": "G", "color": "blue", "rank": "7", "ascii": "71" }, "geometry": { "type": "Polygon", "coordinates": [ [ [123.61, -22.14], [122.38, -21.73], [121.06, -21.69], [119.66, -22.22], [119.00, -23.40], [118.65, -24.76], [118.43, -26.07], [118.78, -27.56], [119.22, -28.57], [120.23, -29.49], [121.77, -29.87], [123.57, -29.64], [124.45, -29.03], [124.71, -27.95], [124.80, -26.70], [124.80, -25.60], [123.61, -25.64], [122.56, -25.64], [121.72, -25.72], [121.81, -26.62], [121.86, -26.98], [122.60, -26.90], [123.57, -27.05], [123.57, -27.68], [123.35, -28.18], [122.51, -28.38], [121.77, -28.26], [121.02, -27.91], [120.49, -27.21], [120.14, -26.50], [120.10, -25.64], [120.27, -24.52], [120.67, -23.68], [121.72, -23.32], [122.43, -23.48], [123.04, -24.04], [124.54, -24.28], [124.58, -23.20], [123.61, -22.14] ] ] } } 

Coordinates are set in the same format.

  • Although the link can find the answer to the question, it is better to point out the most important thing here, and give the link as a source. If the page to which the link leads will be changed, the response link may become invalid. - From the queue of checks - Denis
  • Added excerpts - Mihanik71

The problem was in single quotes.
Put double, it all worked with normal coordinates.