2

My problem:

I am using a web application that uses geojson file to define point data - here is the application:

https://smartcville.com/racks.html

I would like to use the skeleton of the application to make my own maps, again keeping (different) point data in a geojson file. I typed in the json file myself, converted it into geojson with a python script, and confirmed with geojsonlint that the data are properly formatted.

Now the PROBLEM:

the geojson file I have put on my own website (just scp-ed it over). The application does not work any more. I have tried to google for an answer, but, to my surprise, could not find any answers, anywhere.

I figured the following: the original geojson file is here:

var bikeGeoJsonUrl = "https://opendata.arcgis.com/datasets/5fe9482a4ed34551a883355db0f41164_3.geojson";

When I try to load the above geojson file in the browser I get "this is geojson file, what would you like to do, open, save, etc"

My geojson file is on my website:

var bikeGeoJsonUrl  = "https://enjoy-virginia.com/geojson/cville-bike-racks.geojson";

When I try to load it in the browser, it just loads in as a text file, so browser thinks it is just a text.

I found that I could actually use myjson.com site to store my text geojson file and open racks.html file with locations properly.

BUT: I would really want to know how is my geojson file on my website different in format from the way myjson.com is saving the same file?

I also remember a few months ago I had my geojson files stored on github and the applications worked fine, but it has now stopped working.

  • I'm not sure I understand. Do you have some server application reading the geojson? From what I see you are just posting the geojson file on the webserver but there is no interpretation. You need something to interpret it on your architecture, like geoserver/openlayers or leaflet or whatever. – auslander May 25 '18 at 18:16
  • Yes - it is a mapbox/turf application that reads in geojson and then displays the points. It displayed them properly when I save myfile.geojson on myjson.com site, and it does not display them at all when I store exactly the same file on my website ;8-) – Emil Frlez May 25 '18 at 19:05
1

If you compare the http response header, you will see that there is a significant difference.

opendata.arcgis.com

  • Access-Control-Allow-Methods: GET
  • Access-Control-Allow-Origin: *
  • Access-Control-Expose-Headers: ETag
  • Access-Control-Max-Age: 3000
  • Content-disposition: attachment; filename=Bicycle_Rack_Points.geojson
  • Content-Encoding: gzip
  • Content-Type: application/json; charset=utf-8
  • Date: ....
  • ETag: ...
  • Last-Modified: Tue, 14 Nov 2017 15:25:58 GMT
  • Server: ...
  • Vary: ...
  • Content-Length: 5087
  • Connection: keep-alive

your server

  • server: nginx
  • date: ...
  • content-length: 62609
  • last-modified: Thu, 24 May 2018 19:43:19 GMT
  • etag: ...
  • host-header: 192fc2e7e50945beb8231a492d6a8024
  • x-proxy-cache: MISS
  • accept-ranges: bytes
  • X-Firefox-Spdy: ...

The response of the opendata.arcgis.com server contains a Content-Type parameter. This parameter is used to identify the right data visualization or program.

See browser application settings.

  • Yes - but I cannot wrap my head around that. I use wget (or curl) to get the file from arcgis servet: – Emil Frlez May 25 '18 at 19:06
  • ... continuing: "wget opendata.arcgis.com/datasets/…" then I rename the file "mv 5fe9482a4ed34551a883355db0f41164_3.geojson cville-bike-racks.geojson", then I copy the file to my website "scp cville-bike-racks.geojson mywebsite:/geojson". Where does this "Content-Type: application/json; charset=utf-8" comes from? I thought that the JSON file is always a plain text file. That is my problem - where it is coded in that "somefile.geojson" is a geojson file, if it is just a plain text file that only follows JSON format?\ – Emil Frlez May 25 '18 at 19:16
  • 1
    mime.types should contain application/vnd.geo+json geojson; – Andreas W. Bartels May 25 '18 at 19:24
  • OK - but how do I convert my ASCII text file into, say "zipped/UTF-8/Content-Type: application/json" file? – Emil Frlez May 25 '18 at 19:34

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.