0

I'm want make a map for compare 2 coordinates for the same point. Are 1500 different points.

DFINAL<-
structure(list(ACCENUMB = c("G 2771", "G 2771A", "G 6386", "G 7225", 
"G 7225A", "G 7253B", "G 7479", "G 7479A", "G 7479B", "G 7479C"
), LATITUDE = c(21.09, 22.09, 18.88, -13.67, -13.21, 2.67, 16.32, 
18.4, 15.32, 12.32), LONGITUDE = c(-104.42, -104.42, -99.15, 
-72.88, -72.88, -75.98, -99.82, -99.82, -99.82, -99.82), ORIGCTY = c("MEX", 
"MEX", "MEX", "PER", "PER", "COL", "MEX", "MEX", "MEX", "MEX"
), LATITUD_NEW = c(21.17, 21.17, 18.9, -13.67, -13.67, 2.68, 
18.32, 18.32, 18.32, 18.32), LONGITUD_NEW = c(-104.37, -102.37, 
-99.15, -72.89, -75.89, -75.99, -99.82, -94.82, -93.82, -91.82
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
-10L))

The code run well but when I make a search ACCENUMB don't load.

library(tidyverse)
library(leaflet) 

NUM_ORIGCTY <- DFINAL$ORIGCTY %>% unique() %>% length()

Names_ORIGCTY <- DFINAL$ORIGCTY %>% unique()

Colores <- c("#5F11A3","#FF1300","#0F629C", "#F3E908")

pal <- colorFactor(
  palette = c("#5F11A3","#FF1300","#0F0065", "#F70079"),
  domain = DFINAL$ORIGCTY)


m3<-leaflet() %>%
  addTiles() %>%
  #setView(lng=-76.5, lat=2.2 , zoom=9) %>%
  addCircles(data=DFINAL,
    lng = ~LONGITUDE, 
    lat=~LATITUDE,
    color=~pal(ORIGCTY),
    fillOpacity =20,
    weight =9,
    popup = paste("<h3 style='color:#002053'> DATOS </h3>",
      "<b style='color:#214173'> ACCENUMB:</b>",DFINAL$ACCENUMB,"<br>",
      "<b style='color:#214173'> PAIS:</b>",DFINAL$ORIGCTY,"<br>",
      "<b style='color:#214173'> LATITUD:</b>",DFINAL$LATITUDE,"<br>",
      "<b style='color:#214173'> LONGITUD:</b>",DFINAL$LONGITUDE,"<br>"),
    group = ~ ORIGCTY) %>%
  
  addMarkers(data=DFINAL,
    lng = ~LONGITUD_NEW, 
    lat=~LATITUD_NEW,
    group = 'ACCENUMB',
    popup = paste("<h3 style='color:#008000'> DATOS </h3>",
      "<b style='color:#AAAA39'> ACCENUMB:</b>",DFINAL$ACCENUMB,"<br>",
      "<b style='color:#AAAA39'> PAIS:</b>",DFINAL$ORIGCTY,"<br>",
      "<b style='color:#AAAA39'> LATITUD:</b>",DFINAL$LATITUD_NEW,"<br>",
      "<b style='color:#AAAA39'> LONGITUD:</b>",DFINAL$LONGITUD_NEW,"<br>")) %>% 
  
  addLegend(data = DFINAL,'bottomright', pal = pal,
    values = ~ ORIGCTY, title = "PAISES",
    opacity = 0.8,group = "Leyenda")  %>% 
  
  addLayersControl(overlayGroup=Names_ORIGCTY,
    options = layersControlOptions(collapsed=F)) %>%
  
  addResetMapButton() %>%
  
  #####
addSearchFeatures(
  targetGroups = 'ACCENUMB', # group should match addMarkers() group
  options = searchFeaturesOptions(
    zoom=12, openPopup = TRUE, firstTipSubmit = TRUE,
    autoCollapse = TRUE, hideMarkerOnCollapse = TRUE
  )
) %>%
  addControl("<P><B>Hi!</B> Search for ...<br/>
              <ul><li>ACESSION NAME</li>",
    position = 'topleft')
  
m3

enter image description here

The idea is when put the ACCENUMB search this.

1 Answer 1

0

Im find the solution with library(inlmisc) and library(leaflet).

library(inlmisc) 
library(leaflet)

m2 <- leaflet() %>% 
  addTiles() %>% 
  addMarkers(label = ~ACCENUMB, popup = paste("<h3 style='color:#008000'> DIMARY</h3>",
    "<b style='color:#bb042b'> ACCESION: </b>",DFINAL$ACCENUMB, "<br>",
    "<b style='color:#bb042b'> LATITUD: </b>",DFINAL$LATITUD_NEW, "<br>",
    "<b style='color:#bb042b'> LONGITUD:</b>",DFINAL$LONGITUD_NEW,"<br>"), 
    clusterId = "cluster",
    group = "marker", lng = ~ LONGITUD_NEW,  lat= ~ LATITUD_NEW, data= DFINAL) %>% 
  
  AddSearchButton( group = "marker", zoom = 20,  # For add search box in the map.
    textPlaceholder = "Search accesion name...") %>%
  
  addCircles(label = ~ACCENUMB,
    data=DFINAL,
    lng = ~LONGITUDE, 
    lat=~LATITUDE,
   # color=~pal(ORIGCTY),
    fillOpacity = 1,
    weight =8,
    popup = paste("<h3 style='color:#008000'> ORACLE</h3>",
      "<b style='color:#bb042b'> ACCESION: </b>",DFINAL$ACCENUMB , "<br>",
      "<b style='color:#bb042b'> LATITUD: </b>",DFINAL$LATITUDE, "<br>",
      "<b style='color:#bb042b'> LONGITUD:</b>",DFINAL$LONGITUDE,"<br>"))

m2

Th final map make a search when I put the name of ACCESION.

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.