Giter Site home page Giter Site logo

ember-mapbox-gl's Introduction

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

ember-mapbox-gl's People

Contributors

allthesignals avatar danielthall avatar ember-tomster avatar johanrd avatar kategengler avatar kiwiupover avatar kturney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ember-mapbox-gl's Issues

component options should be named the same as mapbox gl's api

This component takes options for this like "paint" but they are called "paintOptions". It'd be more intuitive if these option names matched what they're called in Mapbox GL: https://www.mapbox.com/mapbox-gl-js/example/geojson-polygon/.

Update

Our priorities for this repo are:

We add the maximum power API so no one is ever blocked in using a feature. However, that doesn't preclude us from adding necities on top that layer on to the power user API.

We've identified the need to allow these components to accept an opaque options object:

  • mapbox-gl-layer (currently layoutOptions paintOptions) (pr: #8)

  • mapbox-gl (currently initOptions)

  • mapbox-gl-popup (currently initOptions)

  • mapbox-gl-source (currently sourceId data sourceId, see here)

  • mapbox-gl-marker (currently initOptions)

  • mapbox-gl-control (currently control position, as positionalParams)

  • mapbox-gl-on

  • mapbox-gl-call

mapbox-gl-layer should support 'before' parameter for layer ordering

MapboxGL's addLayer function accepts two arguments, an options hash and a before string. before indicates the order in which a layer is rendered. If left blank, it adds it to the end of the layers array.

Proposed solution is to add a parameter for the component before and pass it if it's defined. Spread syntax would work here to avoid and ugliness in the code.

Make `accessToken` optional

Right now, we require accessToken in the environment for this addon to work, but it's possible to host your own open base styles. Happy to PR this but can you see any issues with this?

Multiple arguments for map.on component

MapboxGL allows the below documented behavior:

    map.on("mousemove", "state-fills", function(e) {
        map.setFilter("state-fills-hover", ["==", "name", e.features[0].properties.name]);
    });

This helps target events to specific layers. A workaround in ember-mapbox-gl is to handle layer selection through queryRenderedFeatures:

    handleMouseover(e) {
      const firstCD = e.target.queryRenderedFeatures(e.point)[0];
    }

If our strategy is to mimic MapboxGL's API as closely as possible, perhaps mapbox-gl-on should allow multiple arguments through spread syntax, expecting a function as the last option.

Cannot find mapbox-gl after upgrade to 0.8.7

Adding "mapbox-gl": "^0.42.0", to devDependencies solves the issue, however.

DCP-APPLE-1770:labs-community-portal mgardner$ ember s
Cannot find module 'mapbox-gl'
Error: Cannot find module 'mapbox-gl'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.resolve (internal/module.js:18:19)
    at Class.treeForVendor (/Users/mgardner/labs-community-portal/node_modules/ember-mapbox-gl/index.js:25:58)
    at Class._treeFor (/Users/mgardner/labs-community-portal/node_modules/ember-cli/lib/models/addon.js:557:33)
    at Class.treeFor (/Users/mgardner/labs-community-portal/node_modules/ember-cli/lib/models/addon.js:517:21)
    at project.addons.reduce (/Users/mgardner/labs-community-portal/node_modules/ember-cli/lib/broccoli/ember-app.js:630:25)
    at Array.reduce (<anonymous>)
    at EmberApp.addonTreesFor (/Users/mgardner/labs-community-portal/node_modules/ember-cli/lib/broccoli/ember-app.js:628:32)
    at EmberApp._processedVendorTree (/Users/mgardner/labs-community-portal/node_modules/ember-cli/lib/broccoli/ember-app.js:1115:24)
    at EmberApp._processedExternalTree (/Users/mgardner/labs-community-portal/node_modules/ember-cli/lib/broccoli/ember-app.js:1143:25)

Could not find module `ember-mapbox-gl/-private/mapbox-loader`

I upgraded the version of ember-cli in our app from ~3.7.1 to ~3.13.1 and I'm consistently getting this error in tests:

Error: Could not find module 'ember-mapbox-gl/-private/mapbox-loader' imported from 'ember-mapbox-gl/components/mapbox-gl'

I dug into it as much as I could with my slight broccoli knowledge and it seems like this lazy loading PR introduced the smart importing of the mapbox-loader file. It seems like that file isn't correctly being added to the broccoli tree using the new Ember CLI.

Edit: can confirm that it work in v0.12.0 and is broken in v0.13.0 and up.

mapbox-gl-layer API should follow Mapbox layer specification

MapboxGL implements their layer specification, which includes a number of properties that are missing from the ember component.

The ember component for a Mapbox layer includes:

  • id
  • type
  • source
  • layout
  • paint
  • metadata
  • ref
  • source-layer
  • minzoom
  • maxzoom
  • filter

One approach may be to define a default config object, like so:

    const defaultOptions = {
      id: options.id ? options.id : this.layerId,
      type: options.type ? options.type : layerType,
      source: options.source ? options.source : sourceId,
      layout: assign({}, layerConfig.layout, options.layout ? options.layout : layoutOptions),
      paint: assign({}, layerConfig.paint, options.paint ? options.paint : paintOptions),
    }

Then assign the overrides:

const options = assign(defaultOptions, this.get('options'));

Relates to #2, PR #8 addresses this issue as well, but doesn't solve it.

Thoughts?

map sometimes fails to load

Thanks a ton for this addon -- overall makes it waaay nicer than having to deal with all the lifecycle stuff manually -- but finding that I'm sometimes getting a blank map rendered:

image

For context, here's what it looks like when it works:

image

I added a mapLoaded event handler which gets triggered fine when the map loads correctly, but when it's showing up blank, the action isn't getting triggered (which i presume is also causing the mapbox-gl component to not yield, and so no subcomponents are rendered). From looking at the requests (and considering the fact that the background is colored), it does seem like the custom style is getting loaded properly.

Having trouble figuring out where the breakdown is happening. Any ideas what could be causing this, or more info i could provide to try to debug?

In case it is relevant, the custom style is set in the global config, the markers are rendered using individual map.marker components

old markers are not removed when backing data changes

I'm generating <map.marker> instances by iterating over an array that is created (in a getter) based on model data. Elsewhere in the same template, I'm also looping over the same array in order to display card entries corresponding to the markers. When the model changes (with a <LinkTo>), the list of cards and the map both update to show the new entries. But the map also still has all the old entries (while the card list is only displaying the current data, as I'd expect). Logging the array confirms that the old entries are no longer present.

It certainly seems like the marker should be getting removed when the component is destroyed: https://github.com/kturney/ember-mapbox-gl/blob/master/addon/components/mapbox-gl-marker.js#L61

So it's very possible i'm just doing something silly, or that something outside ember-mapbox-gl's control that is causing the marker components to not be un-rendered, but having trouble figuring out what the difference is between these two {{#each}} loops, other than one being in a {{mapbox-gl}}

Cannot read property 'removeSource' of undefined

Anyone else getting this error? I upgraded the version to the current one and started having problems
screen shot 2018-03-17 at 11 15 34 pm

I get this error every time a change to a new route after loading the map. If the maps does not have any layers, it works.

I would really appreciate any pointers

"mapbox-gl": "^0.44.0"
"ember-mapbox-gl": "^0.9",
"ember-mapbox-gl-draw": "^1.1.0",

Geolocation control remove

screen shot 2018-04-14 at 2 38 39 pm

I am getting an error when changing route when using the Geolocation control and the user has denied access to location. Is there a way arround this?

This is how I set up the control

this.set('geolocationControl', new MapboxGl.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }) );

And i simply add it like this
{{map.control geolocationControl 'top-right'}}

I would really appreciate any guidelines to solve this.

Bindings for "bounds", "style", other props in mapbox-gl

I'm running into a use case where we manage styles entirely through setStyle of mapbox-gl Map class. This lends itself to some intense actions that fetch and set a style object using a reference to the map instance's setStyle method. This is probably okay, but I can see an argument for a few mapbox-gl-level properties that manage setStyle and fitBounds internally. Using @miguelcobain's Ember Leaflet as an analog, you can see the mapping of properties to Leaflet's internal methods under the "bound options" section:

zoom (uses setZoom())
center (uses panTo())
maxBounds (uses setMaxBounds())
bounds (uses fitBounds())

I know that map.call works for these cases - {{map.call 'fitBounds' bounds}} {{map.call 'setStyle' styleObject}} - but it seems awkward to think of calling functions (as opposed to actions) inside of templates where we should be passing actions and properties. This introduces some non-MapboxGL properties to our API, but I don't think they will collide.

The "Promise aware" part of the title is a nice-to-have - to be able to pass promises down and have components resolve them would be great, but I can imagine having that in a generic API would make it impossible to handle things like failed promises and so on...

I wanted to get your thoughts on this and maybe I could start a branch.

Thank you!

Add popup to marker

Hello! I see several ways of adding popup:

  1. Version of popup from your popup example:
{{#map.popup lngLat=(array -96.7969879 32.7766642)}}
    Dallas, TX
  {{/map.popup}}

this version raises "array is not a helper".
2) Instead of lngLat set marker. I have valid geojson markers, they displayd on the map, but popup not worked, this version raises "setPopup is not a function" here:

marker.setPopup(this.popup);

3) I can set latLng in my component and this works, but I don't like this because I already have markers in my template and pass them through service.

If it's possible, how I can set markers directly to popup tag?

Future of mapbox-gl-on?

mapbox-gl-on helps with binding events and tearing them down afterward. It's super convenient!

That said, it seems a bit awkward as a component...

Would it be more appropriate as a modifier? Custom modifier?:

<MapboxGl
  {{mapbox-on 'dragstart' this.dragStart}}
/>

Or, we can keep the map.on component, and give it some more features as a contextual component:

<map.on @event='click' as |click|>
  {{#if click.lngLat}}
    <map.popup
      @lngLat={{click.lngLat}} {{!-- map.on yields the click event --}}
      as |popup|
    >
      Popup
    </map.popup>
  {{/if}}
</map.on>

Not sure what the drawbacks of the latter would be but I've been playing around with it and it seems to work nicely. I do think the former might be more consistent with newer ember philosophy.

Should mapbox-gl-layer allow blocks?

When invoked without explicit ID, Source and Layer IDs are private and generated automatically:

<map.source
  @options={{hash
    type='geojson'
    data=this.CONSTANTS.EXISTING_TRAILS_URL
  }} as |source|
>
  <source.layer
    @layer={{this.trailStyle}}
    as |layer|
  />
</map.source>

If you want to do anything specific to that layer, such as hover events, <HoverableLayer />, clicking, etc, you'll need to manage your own IDs, and this can get unwieldy and ultimately break the experience of composing layers (as visual elements) inside the templates.

It would be helpful to know at least what this id was through a reference somewhere:

<map.source
  @options={{hash
    type='geojson'
    data=this.CONSTANTS.EXISTING_TRAILS_URL
  }} as |source|
>
  <source.layer
    @layer={{this.trailStyle}}
    as |layer|
  />
    <HoverableLayer
      @layer={{layer}}
    />
  </source.layer>
</map.source>

Would this make any sense or is there a cleaner way?

Fastboot friendliness

I've started working with Fastboot and would like to make ember-mapbox-gl "turn off" its import of mapbox-gl during Fastboot mode. There are a few approaches to this:

  1. Conditionally import mapbox-gl using app.import and make it globally available - this is how ember-leaflet works. Here is a working example: https://github.com/allthesignals/ember-mapbox-gl/tree/fastboot-compatible.

  2. Since we already have ember-auto-import, we can lazy load the dependency (see this issue: embroider-build/ember-auto-import#98). This would mean refactoring the addon in 4 places to call MapboxGL class methods from a component instance method.

With this out of the way, fastboot is trivial to enable.

What are your thoughts?

Policy on upgrading mapbox-gl-js

@danielthall @chriswhong @allthesignals what are y'alls thoughts on how ember-mapbox-gl's version should change when upgrading the underlying mapbox-gl-js library?

It seems excessive to bump our major version every time they release a major version, but if we don't we are potentially transitively making breaking changes.

Alternatively, we could have ember-mapbox-gl depend on "mapbox-gl": "*" and then consuming apps would be in charge of adding a direct dependency on a specific version of mapbox-gl, which ember-mapbox-gl would then pick up. But then we run the risk of the resolved version having some incompatibilities with our bindings.

Or maybe we wing it until they hit 1.0?

Cannot find module '.pnpm/package.json' when running ember-mapbox-gl with pnpm

  1. Clone https://github.com/johanrd/ember-mabox-gl-pnpm-repro or create a fresh ember app with pnpm:
ember new ember-mabox-gl-pnpm-repro --skip-npm
cd ember-mabox-gl-pnpm-repro
pnpm install
pnpm add ember-mapbox-gl mapbox-gl
  1. Run pnpm start and experience the following error:
Cannot find module '.pnpm/package.json' from '/Users/me/ember-mabox-gl-pnpm-repro'

=================================================================================

ENV Summary:

  TIME: Mon Aug 15 2022 20:54:33 GMT+0200 (Central European Summer Time)
  TITLE: ember
  ARGV:
  - /usr/local/Cellar/node@16/16.16.0/bin/node
  - /usr/local/bin/ember
  - serve
  - --proxy
  - http://localhost:5000
  EXEC_PATH: /usr/local/Cellar/node@16/16.16.0/bin/node
  TMPDIR: /var/folders/d6/mxwlnyds65dgg3pkb8kzgxzw0000gn/T
  SHELL: /bin/zsh
  PATH:
  - /Users/me/ember-mabox-gl-pnpm-repro
  - /usr/bin
  - /bin
  - /usr/sbin
  - /sbin
  - /Library/TeX/texbin
  - /Library/Apple/usr/bin
  PLATFORM: darwin x64
  FREEMEM: 573804544
  TOTALMEM: 34359738368
  UPTIME: 1375982
  LOADAVG: 3.62255859375,3.98779296875,4.1123046875
  ENDIANNESS: LE
  VERSIONS:
  - ares: 1.18.1
  - brotli: 1.0.9
  - cldr: 40.0
  - icu: 70.1
  - llhttp: 6.0.7
  - modules: 93
  - napi: 8
  - nghttp2: 1.48.0
  - node: 16.16.0
  - openssl: 1.1.1q
  - tz: 2021a3
  - unicode: 14.0
  - uv: 1.44.1
  - v8: 9.4.146.24-node.21
  - zlib: 1.2.11

ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - code: MODULE_NOT_FOUND
  - codeFrame: [undefined]
  - errorMessage: Cannot find module '.pnpm/package.json' from '/Users/me/ember-mabox-gl-pnpm-repro'
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: Cannot find module '.pnpm/package.json' from '/Users/me/ember-mabox-gl-pnpm-repro'
  - name: Error
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: Error: Cannot find module '.pnpm/package.json' from '/Users/me/ember-mabox-gl-pnpm-repro'
    at Function.resolveSync [as sync] (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected]/node_modules/resolve/lib/sync.js:111:15)
    at EmberApp.import (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:1477:40)
    at Class.included (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected]_ckc3ivbmq2acquefckrorczpfu/node_modules/ember-mapbox-gl/index.js:28:15)
    at Class.superWrapper [as included] (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected]/node_modules/core-object/lib/assign-properties.js:34:20)
    at /Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:721:15
    at Array.forEach (<anonymous>)
    at EmberApp._notifyAddonIncluded (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:719:25)
    at new EmberApp (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:135:10)
    at module.exports (/Users/me/ember-mabox-gl-pnpm-repro/ember-cli-build.js:13:13)
    at Builder.readBuildFile (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/models/builder.js:49:14)
    at Builder.setupBroccoliBuilder (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/models/builder.js:63:22)
    at new Builder (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/models/builder.js:29:10)
    at ServeTask.run (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/tasks/serve.js:49:7)
    at /Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/models/command.js:238:24
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Class.run (/Users/me/ember-mabox-gl-pnpm-repro/node_modules/.pnpm/[email protected][email protected]/node_modules/ember-cli/lib/commands/serve.js:106:5)

=================================================================================

Possibly related to dynamic imports?

update marker position

I'm newbee and maybe this question is super easy, but I don't understand this. How I can change marker data from component? I do it through set(), coordinates of marker changes, but marker itself doesn't change position on the map.

How do you handle map.on('load')?

I tried:

{{#mapbox-gl id='lu-map' initOptions=initOptions as |map|}}
  {{map.on 'load' (action 'handleLoad')}}
{{/mapbox-gl}}

but my handleLoad action never fires...

What I really want to do is disable scrollZoom, but I am not sure where to do it. Thanks!

Error on Building App with `ember-mapbox-gl`

I just migrated my app from ember-g-map to ember-mapbox-gl whenever I fire up my application, it runs into this error :

Build Error (broccoli-persistent-filter:Babel > [Babel: ember-mapbox-gl]) in ember-mapbox-gl/-private/mapbox-loader.js

Cannot read property 'getHash' of null


Stack Trace and Error Report: /var/folders/05/32b0q3c134b032psxm8569f80000gn/T/error.dump.1b86d868572b84d644fcddbf9b9cb36b.log

Export mapbox-gl module

When you use this add-on with the lazyLoad option to true, the _loader private property from the mapbox-gl component could set a mapbox-gl property containing the library that was loaded.

This way, the consuming app didn't have to import the mapbox-gl again, rather using the exposed variable containing the module.

Integration with ember-cli-mirage

I would like to setup ember-cli-mirage such that all XHR requests emitted from core mapbox-gl work with the Mirage passthrough API.

Here's what I've found so far:

  1. MapboxGL's request for the style JSON object throws an "AJAXError (200)" through PretenderJS and one of its dependencies, FakeXMLHttpRequest.
  2. Addressing (but maybe not solving) 1 gets us past the XHR request, but lands us into another issue: style JSON appears to be requested twice, throwing a Mapbox error: "There is already a source with this ID." (Full stack trace below).

image

This is a pretty open-ended issue because I'm not sure where to look next. I don't understand why MapboxGL would be request the style JSON twice. Is this because of how Pretender's FakeXHR object is structured? Or is something happening in Ember Mirage?

You can take a peek at how I landed with this at this branch/commit here: allthesignals/ember-mirage-mapbox-example@ce98473. yarn and ember s and errors will be right there in console.

Thanks!

Full stack trace

server.js:22 Passthrough request: GET https://api.mapbox.com/styles/v1/mapbox/dark-v9?access_token=pk.eyJ1IjoibWF0dGdhcmRuZXJueWMiLCJhIjoiY2o4NTk2dTlzMGFjZDMydWRtY3NsYnFjZSJ9.lA_A4IHM2EGToFiPKFzSug
server.js:22 Passthrough request: GET https://api.mapbox.com/v4/mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7.json?secure&access_token=pk.eyJ1IjoibWF0dGdhcmRuZXJueWMiLCJhIjoiY2o4NTk2dTlzMGFjZDMydWRtY3NsYnFjZSJ9.lA_A4IHM2EGToFiPKFzSug
server.js:22 Passthrough request: GET https://api.mapbox.com/styles/v1/mapbox/dark-v9/[email protected]?access_token=pk.eyJ1IjoibWF0dGdhcmRuZXJueWMiLCJhIjoiY2o4NTk2dTlzMGFjZDMydWRtY3NsYnFjZSJ9.lA_A4IHM2EGToFiPKFzSug
server.js:22 Passthrough request: GET https://api.mapbox.com/styles/v1/mapbox/dark-v9/[email protected]?access_token=pk.eyJ1IjoibWF0dGdhcmRuZXJueWMiLCJhIjoiY2o4NTk2dTlzMGFjZDMydWRtY3NsYnFjZSJ9.lA_A4IHM2EGToFiPKFzSug
mapbox-gl-dev.js:27626 Uncaught Error: There is already a source with this ID
at Style.addSource (mapbox-gl-dev.js:27626)
at Style._load (mapbox-gl-dev.js:27361)
at mapbox-gl-dev.js:27332
at FakeRequest.xhr.onload (mapbox-gl-dev.js:39703)
at dispatchEvent (pretender.js:223)
at XMLHttpRequest.xhr.(:4200/anonymous function) (http://localhost:4200/assets/vendor.js:108440:9)
addSource @ mapbox-gl-dev.js:27626
_load @ mapbox-gl-dev.js:27361
(anonymous) @ mapbox-gl-dev.js:27332
xhr.onload @ mapbox-gl-dev.js:39703
dispatchEvent @ pretender.js:223
xhr.(anonymous function) @ pretender.js:231
load (async)
createHandler @ pretender.js:229
createPassthrough @ pretender.js:247
send @ pretender.js:171
exports.getJSON @ mapbox-gl-dev.js:39708
loadURL @ mapbox-gl-dev.js:27328
setStyle @ mapbox-gl-dev.js:37965
Map @ mapbox-gl-dev.js:37369
_setup @ mapbox-gl.js:49
invoke @ backburner.js:205
flush @ backburner.js:125
flush @ backburner.js:278
end @ backburner.js:410
run @ backburner.js:760
join @ backburner.js:736
join @ backburner.js:477
run.join @ ember-metal.js:4366
(anonymous) @ ember-metal.js:4441
mightThrow @ jquery.js:3534
process @ jquery.js:3602
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
ready @ jquery.js:3878
completed @ jquery.js:3888
mapbox-gl-dev.js:2349 Uncaught AssertionError {name: "AssertionError", actual: false, expected: true, operator: "==", message: "false == true", …}actual: falseexpected: truegeneratedMessage: truemessage: "false == true"name: "AssertionError"operator: "=="stack: "AssertionError: false == true↵ at ImageManager.addImage (http://localhost:4200/assets/vendor.js:78787:7)↵ at http://localhost:4200/assets/vendor.js:91040:45↵ at maybeComplete (http://localhost:4200/assets/vendor.js:89998:13)↵ at http://localhost:4200/assets/vendor.js:89974:13↵ at Image.img.onload (http://localhost:4200/assets/vendor.js:103425:17)"__proto
: Error
fail @ mapbox-gl-dev.js:2349
ok @ mapbox-gl-dev.js:2369
addImage @ mapbox-gl-dev.js:15117
(anonymous) @ mapbox-gl-dev.js:27370
maybeComplete @ mapbox-gl-dev.js:26328
(anonymous) @ mapbox-gl-dev.js:26304
img.onload @ mapbox-gl-dev.js:39755
load (async)
(anonymous) @ mapbox-gl-dev.js:39754
xhr.onload @ mapbox-gl-dev.js:39724
dispatchEvent @ pretender.js:223
xhr.(anonymous function) @ pretender.js:231
load (async)
createHandler @ pretender.js:229
createPassthrough @ pretender.js:247
send @ pretender.js:171
exports.getArrayBuffer @ mapbox-gl-dev.js:39733
exports.getImage @ mapbox-gl-dev.js:39748
module.exports @ mapbox-gl-dev.js:26300
_load @ mapbox-gl-dev.js:27365
(anonymous) @ mapbox-gl-dev.js:27332
xhr.onload @ mapbox-gl-dev.js:39703
(anonymous) @ fake_xml_http_request.js:137
dispatchEvent @ fake_xml_http_request.js:181
dispatchEvent @ pretender.js:221
xhr.(anonymous function) @ pretender.js:231
load (async)
createHandler @ pretender.js:229
createPassthrough @ pretender.js:247
send @ pretender.js:171
exports.getJSON @ mapbox-gl-dev.js:39708
loadURL @ mapbox-gl-dev.js:27328
setStyle @ mapbox-gl-dev.js:37965
Map @ mapbox-gl-dev.js:37369
_setup @ mapbox-gl.js:49
invoke @ backburner.js:205
flush @ backburner.js:125
flush @ backburner.js:278
end @ backburner.js:410
_run @ backburner.js:760
_join @ backburner.js:736
join @ backburner.js:477
run.join @ ember-metal.js:4366
(anonymous) @ ember-metal.js:4441
mightThrow @ jquery.js:3534
process @ jquery.js:3602
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
ready @ jquery.js:3878
completed @ jquery.js:3888
server.js:22 Passthrough request: GET https://api.mapbox.com/fonts/v1/mapbox/DIN Offc Pro Medium,Arial Unicode MS Regular/0-255.pbf?access_token=pk.eyJ1IjoibWF0dGdhcmRuZXJueWMiLCJhIjoiY2o4NTk2dTlzMGFjZDMydWRtY3NsYnFjZSJ9.lA_A4IHM2EGToFiPKFzSug
server.js:22 Passthrough request: GET https://api.mapbox.com/fonts/v1/mapbox/DIN Offc Pro Regular,Arial Unicode MS Regular/0-255.pbf?access_token=pk.eyJ1IjoibWF0dGdhcmRuZXJueWMiLCJhIjoiY2o4NTk2dTlzMGFjZDMydWRtY3NsYnFjZSJ9.lA_A4IHM2EGToFiPKFzSug
mapbox-gl-dev.js:14878 Uncaught TypeError: Cannot read property 'stack' of undefined
at mapbox-gl-dev.js:14878
at mapbox-gl-dev.js:42151
at mapbox-gl-dev.js:14866
at mapbox-gl-dev.js:14856
at mapbox-gl-dev.js:26267
at XMLHttpRequest.xhr.onload (mapbox-gl-dev.js:39724)
at FakeRequest. (fake_xml_http_request.js:137)
at FakeRequest.dispatchEvent (fake_xml_http_request.js:181)
at dispatchEvent (pretender.js:221)
at XMLHttpRequest.xhr.(:4200/anonymous function) (http://localhost:4200/assets/vendor.js:108440:9)
(anonymous) @ mapbox-gl-dev.js:14878
(anonymous) @ mapbox-gl-dev.js:42151
(anonymous) @ mapbox-gl-dev.js:14866
(anonymous) @ mapbox-gl-dev.js:14856
(anonymous) @ mapbox-gl-dev.js:26267
xhr.onload @ mapbox-gl-dev.js:39724
(anonymous) @ fake_xml_http_request.js:137
dispatchEvent @ fake_xml_http_request.js:181
dispatchEvent @ pretender.js:221
xhr.(anonymous function) @ pretender.js:231
load (async)
createHandler @ pretender.js:229
createPassthrough @ pretender.js:247
send @ pretender.js:171
exports.getArrayBuffer @ mapbox-gl-dev.js:39733
module.exports @ mapbox-gl-dev.js:26255
(anonymous) @ mapbox-gl-dev.js:14846
(anonymous) @ mapbox-gl-dev.js:42148
exports.asyncAll @ mapbox-gl-dev.js:42147
getGlyphs @ mapbox-gl-dev.js:14813
getGlyphs @ mapbox-gl-dev.js:28243
receive @ mapbox-gl-dev.js:39605

Popup component should yield `on` contextual component

Mapbox events aren't global and are scoped to certain instances of objects like popup. Would it make sense for mapbox-gl-popup to yield out a hash with the mapbox-gl-on component?

        {{#map.popup
          lngLat=popupLocation
          as |popup|}}
          {{map-popup-content
            onHoverListItem=(action 'handlePopupLinkOver')
            features=popupFeatures}}
          {{! I want this to trigger the action}}
          {{popup.on 'close' (action 'nullifyPopupHover')}}
        {{/map.popup}}

How to handle MapboxLoaderCancelledError

We're seeing some exceptions in our application related to this error and it's not clear why this exception is thrown or how it's intended to be used. Is this an exception we should be concerned with or is it just being used for flow control?

We're hitting both of these occasionally:

if (this._isCancelled) {
throw new MapboxLoaderCancelledError();
}

if (this._isCancelled) {
throw new MapboxLoaderCancelledError();
}

Support dependency injection

The dependency injection pattern makes integration testing a lot easier because test writers can mock certain "difficult" dependencies and inject them into the subject component.

Currently, it's not fully possible to inject a mapbox-gl map instance into the mapbox-gl component. While this is fully supported in its other yielded components, it may be necessary for addon consumers to spin up a wrapping mapbox-gl component for their own needs:

hbs`
	{{#mapbox-gl map=mockedMapInstance as |map|}}
		{{addon-consumer-component map=map}}
	{{/mapbox-gl}}
`

A few things need to happen:

  1. In mapbox-gl component, we set map to null. We could check that map isn't being passed as an arg first.

  2. In _setup, we call the private _onLoad hook, which overwrites whatever map is currently.

  3. Also, in _setup, we will need a way to still fire the mapLoaded hook in case the addon consumer has some important logic there.

Thoughts on this? I'm happy to work on it - all of our projects use maps and it'd be way easier to setup map instances in our tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.