शुरू करेंमुफ़्त में शुरू करें

A Map with a View I

You may have noticed that, by default, maps are zoomed out to the farthest level. Rather than manually zooming and panning, we can load the map centered on a particular point using the setView() function.

leaflet()  %>% 
    addProviderTiles("CartoDB")  %>% 
    setView(lat = 40.7, lng = -74.0, zoom = 10)

Currently, DataCamp has offices at the following locations:

350 5th Ave, Floor 77, New York, NY 10118

Martelarenlaan 38, 3010 Kessel-Lo, Belgium

These addresses were converted to coordinates using the geocode() function in the ggmap package.

  • NYC: (-73.98575, 40.74856)
  • Belgium: (4.717863, 50.881363)

यह अभ्यास पाठ्यक्रम का हिस्सा है

Interactive Maps with leaflet in R

पाठ्यक्रम देखें

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Map with CartoDB tile centered on DataCamp's NYC office with zoom of 6
leaflet()  %>% 
    addProviderTiles("___")  %>% 
    setView(lng = -73.___, lat = 40.___, zoom = ___)
कोड संपादित करें और चलाएँ