Created
September 26, 2016 13:32
-
-
Save bhaskarvk/0c665350557e8ff79a9870cecc88f571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(leaflet) | |
library(htmltools) | |
library(htmlwidgets) | |
# Convert the JS and CSS from | |
# https://github.com/mapshakers/leaflet-icon-pulse/tree/master/src | |
# to proper URLs using rawgit.com | |
pluginDependency <- htmlDependency( | |
"leaflet-icon-pulse",version = "1.0", | |
src = c(href="https://rawgit.com/mapshakers/leaflet-icon-pulse/master/src/"), | |
script = "L.Icon.Pulse.js",stylesheet ="L.Icon.Pulse.css" | |
) | |
registerPlugin <- function(map, plugin) { | |
map$dependencies <- c(map$dependencies, list(plugin)) | |
map | |
} | |
leaflet() %>% | |
addProviderTiles("CartoDB.DarkMatter") %>% | |
setView(-122.4105513,37.78250256, zoom = 12) %>% | |
registerPlugin(pluginDependency) %>% | |
onRender("function(el,x) { | |
var pulsingIcon = | |
L.icon.pulse({iconSize:[5,5],color:'red',heartbeat:0.5}); | |
var pulsingIcon2 = | |
L.icon.pulse({iconSize:[10,10],color:'orange',heartbeat:2}); | |
var marker = | |
L.marker([37.78,-122.41],{icon: pulsingIcon}).bindPopup( | |
'<b>Hello world!</b><br>I am a popup.').openPopup().addTo(this); | |
var marker = | |
L.marker([37.75,-122.39],{icon: pulsingIcon2}).addTo(this); | |
}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment