-
Notifications
You must be signed in to change notification settings - Fork 87
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
Example of how to use divIcon #689
Comments
@MichalBryxi the problem is that you're looking at a div-icon helper. An ember helper's first argument is an array of the positional arguments, and the second is the hash of named arguments. So, the correct way to use the import divIcon from 'ember-leaflet/helpers/div-icon';
<template>
{{divIcon html="x" className='' iconSize=(array 24 40) iconAnchor=(array 12 40)}}
</template> In newer ember versions, you can use functions as helpers. So, another option is to use the leaflet function directly: import { DivIcon } from 'leaflet';
<template>
{{DivIcon (hash html='x' ...)}}
</template> I didn't try this last version. It should work, unless leaflet doesn't like the frozen object that So, ember-leaflet's div-icon helper is working as expected. I think the confusion here was the To import the helper, it should be |
Ha! Thanks so much for the fast reply. Yep, I totally followed the guide here which does indeed say:
When I try your first code example, it does work. In the documentation the sidebar reads: "Helpers -> {{div-icon}}", would it then make sense to fix the import path on that page to give import for helper? And at best also examples of syntax? Heppy to contribute with a PR if yes. |
Unfortunately, those API docs are auto-generated from ember-cli-addon-docs. I haven't found a way to make it output the correct path. PRs are welcome! |
- As per [comment here](miguelcobain#689 (comment)): > I think the confusion here was the import { divIcon } from 'ember-leaflet/helpers/div-icon'; import mentioned in the docs. > That import imports the function, not the helper. > > To import the helper, it should be import divIcon from 'ember-leaflet/helpers/div-icon'; I *think* moving the doc comment _should_(?) then pull the correct documentation into the docs?
Would this PR mean that the documentation would show the "correct" import? |
To prevent seomeone else stepping on this rake:
Leaflet divIcon seems to only require one parameter:
options
hash. But the counterpart fromember-leaflet
seems to require two arguments and the first one seems to be completely ignored. So to use this helper one can:or directly in template via:
The text was updated successfully, but these errors were encountered: