Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a minimum and complete sample of MglGeojsonLayer #211

Open
getJv opened this issue Nov 14, 2020 · 1 comment
Open

Provide a minimum and complete sample of MglGeojsonLayer #211

getJv opened this issue Nov 14, 2020 · 1 comment

Comments

@getJv
Copy link

getJv commented Nov 14, 2020

Hello guys, someone here has a minimal sample of you to use the MglGeojsonLayer?

The sample provided at MglGeojsonLayer it's incomplete .the geoJsonSource and geoJsonLayer data properties are missing and I can't figure out the correct format.

Thanks in advance.

@getJv getJv changed the title Provide a minimu and complete sample of MglGeojsonLayer Provide a minimum and complete sample of MglGeojsonLayer Nov 14, 2020
@cmoine
Copy link

cmoine commented May 10, 2021

I have found a working example with a URL (this is for French area...):

<template>
    <div id="mapid">
        <MglMap accessToken="..."
                mapStyle="https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
                :center="[3, 47]"
                :zoom="5"
		:minZoom="1"
		:maxZoom="19"
                container="mapid">
            <MglGeojsonLayer
                type="fill"
                sourceId="departements"
                :source="departementsSource"
                layerId="departements-contours-layer"
                :layer="departementsContoursLayer"
            />
        </MglMap>
    </div>
</template>

<script>
import Mapbox from "mapbox-gl";
import { MglMap, MglGeojsonLayer } from "vue-mapbox";

export default {
  components: {
    MglMap,
    MglGeojsonLayer
  },
  data() {
    return {
        height: 0,
        departementsSource: {
          data: "/departements-100m.geojson"
        },
        departementsContoursLayer: {
          id: 'departements-contours-layer',
          source: 'departements',
          type: 'line',
          maxzoom: 9,
          paint: {
            "line-width": [
              'case',
              ["boolean", ["feature-state", "hover"], false],
              3,
              1
            ]
          }
        }
    };
  },
  created() {
    // We need to set mapbox-gl library here in order to use it in template
    this.mapbox = Mapbox;
  }
};
</script>

You can find "geojson" file here: https://github.com/etalab/DVF-app/tree/master/static/donneesgeo

I hope this can help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants