rstudio / leaflet

R Interface to Leaflet Maps
http://rstudio.github.io/leaflet/
Other
802 stars 508 forks source link

Custom markers popup anchor point only used if popupAnchorX not equal to zero #203

Open BobTheScientist opened 8 years ago

BobTheScientist commented 8 years ago

When defining a custom icon set to create markers that vary depending on the data, e.g.:

leafIcons <- icons(
  iconUrl = ifelse(quakes1$mag < 4.6,
    "http://leafletjs.com/docs/images/leaf-green.png",
    "http://leafletjs.com/docs/images/leaf-red.png"
  ),
  iconWidth = 38, iconHeight = 95,
  iconAnchorX = 22, iconAnchorY = 94,
  shadowUrl = "http://leafletjs.com/docs/images/leaf-shadow.png",
  shadowWidth = 50, shadowHeight = 64,
  shadowAnchorX = 4, shadowAnchorY = 62
)

to control the anchoring of the popup window, two more parameters are supported, popupAnchorX and popupAnchorY. These are offsets from the iconAnchor coordinates, so a typical usage would be

popupAnchorX = 0,  popupAnchorY = -40

However, these params are not used unless popupAnchorX is something other than zero. The code that checks to see if these are set should be fixed.

kiran777q commented 8 years ago

Hi ,

for iconUr1 variable is it only ifelse can be used ? ( using this condition only 2 colors can be applied) what if i want to apply more than 2 colors.

Ex.like if(quakes1$mag == 4.6 --> some color if(quakes1$mag == 5.6 --> some color if(quakes1$mag == 6.6 --> some color

Could you please help if this can be done ?