Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For this project I am working on, I would like to display an ArcGIS Online FeatureService (JSON) in a webmap that I have built using OpenLayers.

I am able to read the JSON from the service, but I can't seem to 'convert' into a vector layer.

My code is the following:

var data = ($.ajax({
    url: '...',
    success: function (data) {


   var geojson_format = new OpenLayers.Format.GeoJSON();
   var vector_layer = new OpenLayers.Layer.Vector();

This unfortunately produces the following errors:

TypeError: g is null (FF)

TypeError: 'null' is not an object (evaluating 'g.layer=this') (Safari)

Uncaught TypeError: Cannot set property 'layer' of null (Chrome) 

Does anyone know how to fix this?

Thnx in advance!

share|improve this question
additionally, you can use QGIS. Load a shapefile and save as a geojson layer. The geojson format works with both OpenLayers and Leaflet. Make sure you re-project as a shapefile before converting. – geomajor56 Apr 22 '13 at 14:17
Rather than include your solution within your Question, would you be able to transfer it to an Answer, please? It is then quite permissible for you to Accept your own answer. – PolyGeo Apr 26 '13 at 21:01

I would have used the code given at this ticket:

That way you can get the data on the fly, and show it in your OpenLayers map.

share|improve this answer
up vote 0 down vote accepted

I already solved my own question:

It appeared that geoJSON from ArcGIS online is not correctly formatted for use in OpenLayers. If you ever run into this issue yourself, you can convert esri GeoJSON to 'regular' GeoJSON by using this service:

(be sure to check the result properly though, as in this case, there were too many brackets around the coordinates).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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