question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding a basic geojson layer

See original GitHub issue

I 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:open
  • Created 4 years ago
  • Reactions:4
  • Comments:7

github_iconTop GitHub Comments

9reactions
cberthiaumecommented, Jul 1, 2019

@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 in geoJsonSource. I believe there is a bug in the documentation here in the adding layers section. It indicates that the sourceId 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.

7reactions
Blimkcommented, Jun 3, 2019

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);

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found