Skip to content

Instantly share code, notes, and snippets.

@fubits1
Created February 27, 2019 14:57
Show Gist options
  • Save fubits1/409f601173f1dac65790a897d86f1634 to your computer and use it in GitHub Desktop.
Save fubits1/409f601173f1dac65790a897d86f1634 to your computer and use it in GitHub Desktop.
R Mapview Sync
---
title: "R Notebook"
output: html_document
---
```{r echo=FALSE, warning=FALSE, message=FALSE}
library(tidyverse)
library(leaflet)
library(mapview)
library(sf)
```
```{r echo=FALSE}
Coords <- ggmap::geocode("Kidal, Mali", source = "dsk", output = "latlon")
Object_sf <- sf::st_sfc(sf::st_point(c(Coords$lon, Coords$lat)), crs = 4326)
```
```{r echo=FALSE}
m1 <- leaflet() %>%
addTiles() %>%
addMarkers(Coords$lon, Coords$lat) %>%
setView(Coords$lon, Coords$lat, zoom = 15)
```
```{r echo=FALSE}
mapparam <- c("Esri.WorldImagery")
m2 <- mapview(Object_sf, map.types = mapparam)
```
```{r}
mapview::sync(m1,m2)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment