Git Product home page Git Product logo

Comments (6)

christhaxter avatar christhaxter commented on June 14, 2024 1

Amazing thanks. L.divicon worked really nicely - I also managed to customise it making the css styling on the server side for more reactivity. Thanks again.

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 14, 2024

Hey, I just pushed 7afffe8, which exposes the new argument name to addPlayback. With it you can access feature.name in the marker function and style the icons as you want.

marker =  htmlwidgets::JS("
     function(feature) {
       var color = 'blue'; 
       var icon = null;
       switch (feature.name) {
              case 'ALPHA':
                  color = 'red';
                  icon = 'glass';
                  break;
       }
       return {
        icon: L.AwesomeMarkers.icon({
                   icon: icon,
                   markerColor: color
                   })
        }
      }")

You can see a full example here:
https://github.com/trafficonese/leaflet.extras2/blob/master/inst/examples/playback_app_awesomemarkers.R
Note that I also have to include the AwesomeMarker dependencies (leaflet:::leafletAwesomeMarkersDependencies()).

from leaflet.extras2.

christhaxter avatar christhaxter commented on June 14, 2024

Thanks, this is really neat addition and very much appreciated! Yes if it was possible to include the awesomemarker dependencies as well super, e.g. I guess for the moveable markers to act more like circleMarkers perhaps? Incidentally, this is for animation visualisation of animal tracking data in a Shiny app and I've found yours to be a fast render of the animation so far in my trials.

Not looking to leave a full "wish list" here :) but I also wondered as well if it was possible to retain lagged interpolated points on the map for a period of time before they disappear leading up to the current location, if that makes sense? Reason for that question is because I was experimenting with some other options in leaftime inspired by this discussion for polylines in that regard, but perhaps this is more of a technical challenge, e.g. perhaps even lines and points on the same map feeding off the same play slider...

Totally fine to leave this query as it is though if the second paragraph is a step too far. Thanks so much for your help again.

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 14, 2024

Hm I guess the movableMarker is not a circleMarker as the GPS-track is already visualized with circleMarkers and I think its nice be able to include an Icon.

For the lagged interpolated points, I guess that should be raised in the underlying JS-library.

from leaflet.extras2.

christhaxter avatar christhaxter commented on June 14, 2024

Thanks. Fully appreciate this function as it is, it is great addition (was just exploring options).

Just one more thing - is there an easy way to pass hex colours through to the switch? e.g.

case 'ALPHA':
  color = '#ff7800';
  icon = 'glass'; 
 break;

At the moment the above would default to 'red' I think (in my version), so expect I am missing something obvious.

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 14, 2024

As per the https://github.com/lennardv2/Leaflet.awesome-markers definition, the Awesome Markers can only have a few colors and not hex-colors.

markerColor Color of the marker 'blue' 'red', 'darkred', 'orange', 'green', 'darkgreen', 'blue', 'purple', 'darkpurple', 'cadetblue'

But you could use L.divIcon and use your own CSS-class for every Marker. I just pushed an example for this:
https://github.com/trafficonese/leaflet.extras2/blob/master/inst/examples/playback_app_divicon.R

from leaflet.extras2.

Related Issues (20)

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.