Abstract

This is week 2 assignment to demonstrate use of library leaflet.
In this article I will use embedded dataset of quakes.
The records of the quakes in Philipines region will be clustered on the map and each recording will show popup with its location, depth and magnitude.
Image of “Quake” from hiclipart.com was used for marker.

Presentation of the data

head(quakes)
##      lat   long depth mag stations
## 1 -20.42 181.62   562 4.8       41
## 2 -20.62 181.03   650 4.2       15
## 3 -26.00 184.10    42 5.4       43
## 4 -17.97 181.66   626 4.1       19
## 5 -20.42 181.96   649 4.0       11
## 6 -19.68 184.31   195 4.0       12

Preparing markers for quake epicenter:

quakeIcon<- makeIcon(
    iconUrl = "http://tadbox.com//quake_hd.png",
    iconWidth = 31*215/230, iconHeight = 31,
    iconAnchorX = 31*215/230/2, iconAnchorY = 16
  )

Preparing popup with the information of Location, depth of the quake and its magnitude:

  quakeDetails<-paste("Lat:",quakes$lat, "Lng:",quakes$long, "<br/>", "Depth: ", quakes$depth, "<br/><b>", "Magnitude: ", quakes$mag,"</b><br/>")

And now ready to render the map with clusters:

  quakes %>% leaflet() %>% 
    addTiles() %>% 
    addCircles(weight=3,  popup = quakeDetails, color = "wheat") %>%
    addMarkers(clusterOptions = markerClusterOptions(),icon=quakeIcon, popup = quakeDetails)

End of the assessment