Problem accessing geojson properties when generated inline
See original GitHub issuePerhaps I am missing something, but there appears to be a problem in accessing inline geoJson objects.
The following spec, which loads a geoJson file works as expected:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"width": 200, "height": 200,
"data": {
"url": "https://gist.githubusercontent.com/jwoLondon/6caab27b0d131c74c194efd943389201/raw/e9ea15b56001dfac9c3795dff4f2a0f67dbfc710/geojsontest.json",
"format": { "type": "json", "property": "features" }
},
"projection": { "type": "orthographic" },
"encoding": {
"color": {
"field": "properties.myRegionName",
"type": "nominal"
}
},
"mark": "geoshape"
}
But if I generate the same content inline, I do not seem to be able to access the myRegionName
property:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"width": 200, "height": 200,
"data": {
"values": [
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [ [ [-3,52], [4,52], [4,45], [-3,45], [-3,52] ] ]
},
"properties": { "myRegionName": "Southern region" }
},{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [ [ [-3,59], [4,59], [4,52], [-3,52], [-3,59] ] ]
},
"properties": { "myRegionName": "Northern region" }
}
]
}
],
"format": { "type": "json", "property": "features" }
},
"projection": { "type": "orthographic" },
"encoding": {
"color": {
"field": "properties.myRegionName",
"type": "nominal"
}
},
"mark": "geoshape"
}
This spec generates the error : TypeError: undefined is not an object (evaluating 'e.hasOwnProperty’)
Is this perhaps related to one of the issues in #3369, or is there some other way of accessing nested inline fields?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Problem with loading GeoJSON file in OpenLayers generated ...
The problem seems to be that the features-array in your featurecollection contains three features, two with geometry:none and one with just ...
Read more >Why inline geojson source must have a properties ... - GitHub
When set the "properties": { "id": 1 }, , works as expected. Note that mapbox-gl-js does not have this problem.
Read more >Chapter 7 GeoJSON | Introduction to Web Mapping
The "coordinates" property is specified with an array. The basic unit of the coordinate array is the point coordinate. According to the GeoJSON...
Read more >geojson - Leaflet - map layers not loading - Stack Overflow
I am getting the error: Uncaught TypeError: Cannot read property 'features' of null at Object.t.choropleth.n.exports [as choropleth]. Is this a ...
Read more >Work with markers in Mapbox.js | Help
You can add markers to your map using Leaflet or with GeoJSON using Mapbox.js. ... of the Mapbox D.C. and San Francisco offices...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @iliatimofeev, that’s helpful and clarifies where the problem lies, and so as far as I can see once the documentation is updated this issue can be closed.
Ok, so you have something planned? Would suggestions for some minimal examples be helpful?