GNOME Bugzilla – Bug 778794
Loading GeoJSON doesn't work
Last modified: 2017-03-09 20:36:34 UTC
As part of checking that a patch I made didn't break gnome-maps I found that the GeoJSON from the following URL didn't load: http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT%20*%20FROM%20nz_tour&format=geojson With MAPS_DEBUG=1 I get this: Gjs-Message: JS LOG: MapView<.openShapeLayers/<@resource:///org/gnome/Maps/js/mapView.js:260 MapView<.openShapeLayers@resource:///org/gnome/Maps/js/mapView.js:271 wrapper@resource:///org/gnome/gjs/modules/lang.js:178 LayersPopover<._onLoadLayerClicked/<@resource:///org/gnome/Maps/js/layersPopover.js:127 main@resource:///org/gnome/Maps/js/main.js:47 run@resource:///org/gnome/gjs/modules/package.js:192 start@resource:///org/gnome/gjs/modules/package.js:176 @/usr/bin/gnome-maps:5
Going a bit deeper: If I change shapeLayer.js:newFromFile to: function newFromFile(file, mapView) { let contentType = Gio.content_type_guess(file.get_uri(), null)[0]; log("contentType:" + contentType); log("SUPPORTED_TYPES: " + JSON.stringify(SUPPORTED_TYPES)); I get this in the logs: Gjs-Message: JS LOG: contentType:application/geo+json Gjs-Message: JS LOG: SUPPORTED_TYPES: [null,null,null] So SUPPORTED_TYPES doesn't seem to get initialized properly.
The fixing of how we loop through supported_types in your other bug does not fix this? Changing for for (x in y) { } ...
No it doesn't I'll see if I can't look a bit closer on this now.
The strange thing is that it seems to get an array filled with nulls there, and opening .gpx files _does_ work. Will need to try doing that with this debug logging turned on.
Created attachment 347500 [details] [review] geoJSONShapeLayer: Add additional mime type It seems GeoJSON files are identified by later versions of the mime type database as application/geo+json. So add this type to the supported ones for the shape layer implementation.
Review of attachment 347500 [details] [review]: Patch itself looks good but nitpicks on commit log (mostly for furture reference): * instead of "additional", let's specify the mimetype. To keep the shortlog short still, I'd sacrifice on module prefix instead. * Would be nice if we don't break the lines early (before 74 chars) just to start new sentences. It only unnecessarily makes the `git log` output longer and looks weird.