I am learning to use GeoExt and OpenLayers, and I want to reproduce one of the examples given at the GeoExt website. The script calls a GeoJSON file containing the position of Alp summits. I downloaded it via wget and put it in data/summits.json.

I copy pasted the JavaScript file in a local folder, but when I run it in Firefox, I get a not well formed error. I got the same error with several other examples involving a JSON file. I looked for similar problems on the web, but couldn't find an answer. What am I missing?

The part of the script adding the layer from the JSON file is

var summits = new OpenLayers.Layer.Vector("Summits",{
    strategies: [new OpenLayers.Strategy.Fixed()],
    protocol: new OpenLayers.Protocol.HTTP({
        url: "data/summits.json",
        format: new OpenLayers.Format.GeoJSON()
    styleMap: new OpenLayers.StyleMap(new OpenLayers.Style({},{rules: rules}))

I used the same bit of code in several other examples provided by the website (modulo the styleMap part) with always the same error.

  • I think you may need to pull the json file from a web server not a file (or at least a full URL)
    – Ian Turton
    May 29, 2013 at 8:47
  • 2
    Try validating your geojson: geojsonlint.com
    – atlefren
    May 29, 2013 at 9:02

1 Answer 1


Your problem may be the line 10 of your vector-legend.html, you're probably using:

<script type="text/javascript" src="../script/GeoExt.js"></script>

but you need to download that file to your pc first with:

wget http://api.geoext.org/1.1/GeoExt/script/GeoExt.js

and then edit the HTML like:

<script type="text/javascript" src="GeoExt.js"></script>

or even easier, simply use:

<script type="text/javascript" src="http://api.geoext.org/1.1/GeoExt/script/GeoExt.js"></script>

that should do the trick. BTW, the summits.json works perfectly after using wget.

Hope this helps,

  • Okay, apparently the problem was elsewhere. The GeoExt.js I was using was coming from an Opengeo workshop. By using the script directly from api.geoext.org, the json appears correctly. The "not well formed" is still there though. I used @atlefren website, and it did not return any error
    – Bulkilol
    May 29, 2013 at 11:45
  • so probably the opengeo workshop is the problem. Please consider upvoting if the answer helped you.
    – Gery
    May 29, 2013 at 11:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.