Skip to content

grodriguez85/ember-mapbox-gl

This branch is 44 commits ahead of, 2 commits behind kturney/ember-mapbox-gl:master.

Folders and files

NameName
Last commit message
Last commit date
Dec 26, 2021
Nov 8, 2021
Oct 20, 2023
Mar 29, 2023
Mar 29, 2022
Oct 20, 2023
Oct 20, 2023
Mar 29, 2022
May 6, 2020
Apr 18, 2017
Dec 26, 2021
Feb 15, 2023
Dec 26, 2021
Dec 26, 2021
Dec 26, 2021
Mar 29, 2022
Mar 29, 2022
Aug 21, 2017
Feb 26, 2018
Nov 8, 2021
Jan 24, 2022
Dec 26, 2021
Feb 15, 2023
Apr 5, 2022
Apr 18, 2017
Oct 20, 2023
Nov 8, 2021
Oct 20, 2023
Oct 20, 2023

Repository files navigation

ember-mapbox-gl

Latest NPM release GitHub Actions Build Status Ember Observer Score

Ember integration with mapbox-gl-js.

Installation

ember install ember-mapbox-gl

Then, add your Mapbox access token to config/environment.js:

module.exports = function(environment) {
  let ENV = {
    'mapbox-gl': {
      accessToken: 'ACCESS TOKEN HERE'
    },
}

Compatibility

  • Ember.js v3.24 or above
  • Ember CLI v3.24 or above
  • Node.js v12 or above

API Documentation

See the detailed API Documentation.

Example

Note: The example below uses ember-composable-helpers.

Add the following map options to config/environment.js to style the map, set a default zoom level, and to provide a default centerpoint:

'mapbox-gl': {
  accessToken: 'ACCESS TOKEN HERE',
  map: {
    style: 'mapbox://styles/mapbox/basic-v9',
    zoom: 13,
    center: [ -96.7969879, 32.7766642 ]
  }
},
import Controller from '@ember/controller';

export default Controller.extend({
  marker: {
    type: 'FeatureCollection',
    features: [
      {
        type: 'Feature',
        geometry: { type: 'Point', coordinates: [ -96.7969879, 32.7766642 ] }
      }
    ]
  },

  actions: {
    mapClicked({ target: map, point }) {
      console.log(map, point);
    }
  }
});
{{#mapbox-gl class='map-container' initOptions=(hash pitch=30) as |map|}}
  {{map.on 'click' (action 'mapClicked')}}

  {{#map.source options=(hash type='geojson' data=marker) as |source|}}
    {{source.layer layer=(hash
      type='circle'
      paint=(hash circle-color='#007cbf' circle-radius=10))}}
  {{/map.source}}
{{/mapbox-gl}}

The above example does the following:

  • Creates an instance of a map
  • Attaches a mapClicked action when anywhere on the map is clicked
  • Generates a geojson map source (marker)
  • Draws a blue circle on the map at the coordinates provided by marker

About

Ember integration for Mapbox GL JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 59.8%
  • TypeScript 34.0%
  • Handlebars 3.8%
  • HTML 2.2%
  • CSS 0.2%