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

Different Markers #69

Open
james04gr opened this issue Oct 2, 2018 · 3 comments
Open

Different Markers #69

james04gr opened this issue Oct 2, 2018 · 3 comments

Comments

@james04gr
Copy link

I am using the Example 2 but i dont understand where in the playbackOptions do we pass the different icons that we want to show in each route....

@danikane
Copy link

danikane commented Dec 14, 2018

http://leafletplayback.theoutpost.io/examples/example_2.js

var _colorIdx = 0,
        _colors = [
          'orange',
          'green',
          'blue',
          'purple',
          'darkred',
          'cadetblue',
          'red',
          'darkgreen',
          'darkblue',
          'darkpurple'
        ];
        
    function _assignColor() {
        return _colors[_colorIdx++%10];
    }

and then:

        marker: function(){
            return {
                icon: L.AwesomeMarkers.icon({
                    prefix: 'fa',
                    icon: 'bullseye', 
                    markerColor: _assignColor()
                }) 
            };
        }

You can pass feature to the marker function and use the properties of the feature to style it as you want.

@christhaxter
Copy link

christhaxter commented Feb 17, 2023

Hi, I am using the R version of this plugin through the addPlayback() function in leaflet.extras2. Apologies this is not directly a js question, but I don't suppose you could help with altering the moveable marker icon and colours as above? E.g. I was expecting something like the below using htmlwidgets::JS but it is not working, and I am probably doing something wrong:

leaflet() %>%
  addTiles() %>%
  addPlayback(data = data,
options = playbackOptions(
 marker =  htmlwidgets::JS(
                                              "
                                              function() {
                                              return L.AwesomeMarkers(
                                              {
                                              prefix: 'fa',
                                              icon: 'bullseye',
                                              markerColor: 'darkgreen'
                                              }
                                              );
                                              }
                                                  "
                                        )
))

@danikane
Copy link

Hi @christhaxter, I'm not familiar with R at all, but is the above syntax correct?

I saw this usage of the JS function:
https://www.rdocumentation.org/packages/htmlwidgets/versions/1.6.1/topics/JS

Also there is a difference in the return of your stringified function (returns the L.AwesomeMarkers object) and the one in the example (which returns an object with an icon property = L.AwesomeMarkers.icon function, nothing more than instantiating an object from the Icon class)
https://github.com/lennardv2/Leaflet.awesome-markers/blob/2.0/develop/dist/leaflet.awesome-markers.js#L118

Apart from that I can't really tell what the issue is, maybe start there ^.

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

3 participants