npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-cli-mapbox-map

v0.2.0

Published

Mapbox map component for Ember.js web apps.

Downloads

1

Readme

ember-cli-mapbox-map

This addon is a go-to solution to include and configure Mapbox.js library into Ember and easily use it as a native component.

Installation

ember install ember-cli-mapbox-map

Initial configuration

In order to make this addon work properly for you, you need to define accessToken and mapId in your config/environment.js:

ENV['mapbox'] = {
    accessToken: 'YOUR_MAPBOX_TOKEN_HERE',
    mapId: 'YOUR_MAPBOX_MAP_ID_HERE'
  };

Using mapbox as a component

Include mapbox component in any template where you would like to display a map.

{{mapbox-map
  model='http://getyourmarkers.com'
  attributionControl=false
  zoomControl=false}}

Mapbox map customization

The component provides you with a lot of attributes that you can change to customize the map and its data.

Map controls

attributionControl

This property is used to display default Mapbox attributions at the bottom corner on the map. Defaults to true. Pass false if you don't want to display Mapbox and OpenStreetMap mentions.

{{mapbox-map attributionControl=false}}

zoomControl

This property is used to display zoom controls on the map. Defaults to true. Pass false if you don't want to display zoom controls.

{{mapbox-map zoomControl=false}}

Map model

The component has its own model, like your Ember.Route. This model is data which contains markers in GeoJSON format to display on the map. You should pass to model property a path on your API, where mapbox component can grab markers from.

Passing remote path of model to a component

{{mapbox-map model='/markers'}}

will result into querying to http://yourdomain.com/markers.

{{mapbox-map model='http://anotherdomain.com/markers'}}

will result into query to http://anotherdomain.com/markers.

Passing model directly to a component

You can also get markers from your backend API or any other location in model hook on your route and then pass this loaded model into a component.

export default Ember.Route.extend({
  model: function() {
    return this.store.findAll('marker');
  }
});

And then pass to a markers property on a component.

{{mapbox-map markers=model}}

Or if you have defined marker in the property on your controller:

export default Ember.Controller.extend({
  markers: {
  // ...
  }
});

You can then pass controller's property to a component:

{{mapbox-map markers=markers}}

Icon customization of the marker

If you have custom image for marker, then you can specify it in mapbox-map component and it automatically will replace default icons with your shiny ones. By default, customIcons property is false.

{{mapbox-map customIcons=true}}

Custom popup content

You can also customize the way your template is displayed inside popups when you click on a marker. In order to do this, you should define popupContent property on your controller and pass it to the mapbox-map component.

export default Ember.Controller.extend({
  popupContent: function(marker) {
    return '<h1>Hello</h1>' +
           '<strong>Name:</strong> ' +
           marker.feature.properties.title +
           '<br/><strong>Address:</strong> ' + marker.feature.properties.description +
           '<br/><span style="color:red;">This is a red text.</span>';
  }
});
{{mapbox-map popupContent=popupContent}}

Running

  • ember server
  • Visit your app at http://localhost:4200.

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.