google maps - Uncaught InvalidValueError: not a Feature or FeatureCollection -


after seeing recent video google devs decided regional map of uk. there couple of possibilities mentioned on site i've since had dismiss*

so ended using site (example page of data downloads): http://mapit.mysociety.org/area/11804.html

notice geojson download third link down? 1mb file size. when first tried using map:

function initmap(){     var ukc = new google.maps.latlng(54.8, -4.6);     var mapoptions = {         zoom: 5,         center: ukc     };     map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions);     map.data.loadgeojson('http://local.mapsite.com:8080/app/jsondata/eastern.json'); }  $(document).ready(function(){     initmap(); }); 

i got above error: uncaught invalidvalueerror: not feature or featurecollection

fix attempt 1 - google it

googling error came nothing useful.

fix attempt 2 - shrink it

i thought maybe sheer size of beast shrank using mapshaper.org more manageable 10k. still no luck!

fix attempt 3 - lint it

maybe geojson badly formatted? how considering right there working on mapit.org found wonderful site linting geojson data: http://geojsonlint.com/ - linting worked! apparently geojson worked drew polygon of east anglia on uk in glory (note geojsonlint uses openstreetmap). still no luck

fix attempt 4 - topojson

hoping combine regions , compress @ same time thought desperately topojson work. tried - still got same error. here's link topojson file shared on google drive: someregions.json no luck.

fix attempt 5 - add feature code start of json

the current geojson file starts {"bbox":[-0.745702,51.448473,1.767999,52.98991],"type":"geometrycollection","geometries":...

i added:

{"type": "feature", "bbox":[-0.745702,51.448473,1.767999,52.98991],"type":"geometrycollection","geometries": 

fix attempt 6

retry different regions donm't contain bbox parameter near start start { "type": "polygon", "coordinates": [ [ [ -3.155785, 53.427385 ], [ -3.151533, 53.427328 ], [...

still no luck.

in (failed) conclusion

even though proved file small enough, linted , worked elsewhere still got infuriating error messages console when attempting put them on map.

uncaught invalidvalueerror: not feature or featurecollection 

here shrunk geojson file publically shared via gdrive: https://drive.google.com/file/d/0b42aec8rkchtnvnzzuxqv0y5rkk/edit?usp=sharing

my next attempts involve topojson compress regions 1 internal borders wanted check here first see if knows problem be? because may few hours of futile energy wasted.

* attempting use ordanance survey data failed provided shd data , not shp stated in previous question on subject. couldn't convert geojson using ogr2ogr.

the specification geojson can found @ http://geojson.org/geojson-spec.html relevant (though experimental) google maps api documentation can found @ https://developers.google.com/maps/documentation/javascript/3.exp/reference#data

so looks geojson acceptable google maps, need wrap polygon (or similar) returned mapit in feature or featurecollection, here's example bermuda-triangle:

  { "type": "featurecollection",     "features": [       { "type": "feature",          "geometry": {            "type": "polygon",            "coordinates":                [                 [                   [-80.190262,25.774252],                   [-66.118292,18.466465],                   [-64.75737,32.321384],                   [-80.190262,25.774252]                 ]               ]          }       }     ]   } 

for data provided http://mapit.mysociety.org/area/11804.html has be:

  { "type": "featurecollection",     "features": [       { "type": "feature",          "geometry": /** paste here complete output of                           http://mapit.mysociety.org/area/11804.geojson **/       }     ]   } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -