0

I imported GeoJSON to my map, but my browser shows me the following error message:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

enter image description here

(clickable)

This is my script :

< !doctype html >
  < html lang = "en" >
  < head >
  < link rel = 'stylesheet'
href = 'css/ol.css' >
  < style > #map {
    height: 100 % ;
    width: 100 % ;
  } < /style>
    <title>OpenLayers 3 example</title >
  < script src = "build/ol.js"
type = "text/javascript" > < /script>
  </head >
  < body >
  < h1 > My Map < /h1>
    <div id="map"></div >
  < script type = "text/javascript" >


  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.GeoJSON({
          projection: 'EPSG:4326',
          url: 'gjson/test.geojson'
        })
      })
    ],

    view: new ol.View({
      center: [0, 0],
      zoom: 2

    })
  }); < /script>
  </body >
< /html>

Where I made an error? I don't know how to resolve this problem.

2
  • Unrelated, but why do you have all the spaces inside the tags, e.g., < head > instead of <head>?
    – jmdeldin
    Feb 28, 2016 at 17:56
  • editor in webside created spaces. " POST json file" what is it mean ...sorry I am beginner mainly I work in example from ol3
    – Agnieszka
    Feb 28, 2016 at 17:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.