Adding a basic geojson layer
See original GitHub issueI am having some confusion about the layer
prop and how it ties into the component. I have a test geojson feature but I can’t get it to add to the map.
<MglGeojsonLayer
sourceId="mySourceId"
:source="geoJsonSource"
layerId="myLayerId"
:layer="geoJsonlayer"
/>
geoJsonSource: {
type: "Feature",
geometry: {
type: "Point",
coordinates: [125.6, 10.1]
},
properties: {
name: "Dinagat Islands"
}
},
geoJsonlayer: {
type: "circle",
paint: {
"circle-color": "#00ffff"
}
},
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7
Top Results From Across the Web
Add a feature layer as GeoJSON | MapLibre GL JS
To add GeoJSON from a feature service , you need to define a source of type geojson and reference the feature layer ....
Read more >Using GeoJSON with Leaflet
GeoJSON objects are added to the map through a GeoJSON layer. To create it and add it to a map, we can use...
Read more >Walkthrough: Adding interactive GeoJSON layers in Leaflet
This walkthrough builds on some of the previous sections of the lesson to show how you can add interactive GeoJSON layers to your...
Read more >Leaflet Tutorial #5: Add GeoJSON using JavaScript - YouTube
Learn how to add a GeoJSON on a map using Leaflet, an open-source JavaScript library. Sample code for a map viewer: ...
Read more >How do I add a GeoJSON layer to Fulcrum?
Select GeoJSON as the layer source · Give the layer a name · Enter in the layer's URL or Past the raw GeoJSON...
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 FreeTop 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
Top GitHub Comments
@gorbypark, I was having similar issues getting my map to render features. I forked your codepen and got it working here. I made two changes.
First, I changed the structure of
geoJsonSource
to match what @Blimk described.Second, I modified line 5 of App.vue to read,
:sourceId="geoJsonSource.data.id"
. This matches the location of the id ingeoJsonSource
. I believe there is a bug in the documentation here in the adding layers section. It indicates that thesourceId
will be in:sourceId="geoJsonSource.id"
which I think is incorrect.It’d be really nice to have some working examples in the documentation. The codepen here might serve as a starting point.
Hello gorbypark, The type for object geoJsonSource must be geojson
geoJsonSource: { 'type': 'geojson', 'data': { 'id': 'test', 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'LineString', 'coordinates': [ [-122.48369693756104, 37.83381888486939],
Here is the extract of the source code in vue-mapbox.umd.min.js :
var t = s({ type: "geojson" }, this.source); try { this.map.addSource(this.sourceId, t);