Skip to content

Instantly share code, notes, and snippets.

@Martin-Jung
Forked from fubits1/mapview_sync.Rmd
Created February 27, 2019 22:39
Show Gist options
  • Save Martin-Jung/7b551021ff266f425141f2aae7a68dab to your computer and use it in GitHub Desktop.
Save Martin-Jung/7b551021ff266f425141f2aae7a68dab 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