3

I am fairly new to all of this and am looking for some guidance. Any information is appreciated!

I am trying to use leaftlet to display shapefiles from an ArcGIS Server using the REST URL. I have seen several examples of this (http://geojason.info/leaflet-vector-layers/demos/arcgis-server/) (http://blog.davebouwman.com/2011/08/04/leaflet-lean-mean-javascript-maps/) and have tried to apply the same formatting to my own code but have not been successful in actually displaying the data on the map. Because I'm not extremely familiar with this stuff I'm not sure what my next step should be to solve the problem.

  • Do you have a sample of what you have tried and where it breaks? As far as I can tell, your fist link should still work. You can post sample code on jsfiddle.net to quickly share. – Rene Rubalcava Jul 15 '13 at 18:31
  • 1
    Have you had a look at the Leaflet plugin developed by ESRI: github.com/Esri/esri-leaflet – Devdatta Tengshe Jul 16 '13 at 3:27
  • I have. Still the data doesn't display. – bailey Jul 16 '13 at 18:35
3

In addition to my comment, the main issue is converting the EsriJSON to GeoJSON for your data. There have been a handful of projects that can do this, but Esri recently released their esri-leaflet library that can interact directly with ArcGIS Server services.

For your vector data, you can do this manually by trying this esri util to convert EsriJSON to GeoJSON, and then load it into Leaflet as normal via L.GeoJSON.

Not a perfect example, but the conversion could look like this:

    var map = new L.Map('map');
    var esridata = data; // assume this came from an esri map service
                         // via an ajax request
    var geojs = jsonconverter.toGeoJson(esridata);
    var geojsonLayer = new L.GeoJSON();
    map.addLayer(geojsonLayer);
    geojsonLayer.addGeoJSON(geojs);
  • Thanks for the response! I took the code from the first link and first example and basically just swapped in the REST URL for my data. I was assuming that would work but I only get a blank basemap showing up. It wasn't clear to me if I needed to add anything else. – bailey Jul 15 '13 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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