I've been trying to create a proportional symbols map using Leaflet and jQuery. Currently getting the error "invalid Geojson object." I have validated my json using jsonlint.com and it is valid. I think the error must be from my method of getting the json.
I ran into a CORS error trying to use my json as a local file, so I have hosted it online, here is the URL: https://api.myjson.com/bins/nh71g
I have tried to put it in my Javascript as follows:
$.getJSON("https://api.myjson.com/bins/nh71g")
I tried using $.get
instead of $.getJSON
but that didn't work either.
Not sure how to proceed. Can someone help?
I've tried to validate yours geoJson through different sites and http://geojsonlint.com/ doesn't work until I'd removed
"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},
If it doesn't help - look at yours Leaflet code, you should put your data inside L.geoJSON() method
This seems to be working, were you possibly not handeling the result properly?
$.getJSON("https://api.myjson.com/bins/nh71g", function(data){ $('#result').text(JSON.stringify(data)) })
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id='result'></div>
EDIT: Also, when testing here: http://geojsonlint.com/ it says that your geoJSON is not valid with a little better error message Line 1: old-style crs member is not recommended, this object is equivalent to the default and should be removed
EDIT2: It appears that removing "crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}}
from your json makes it valid and plots properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.