how to add both maps (instore and onlineloc) on one map

library(leaflet)
onlineloc=data.frame(lat=runif(orders,29,34),
                     long=runif(orders,69,72))
#> Error in runif(orders, 29, 34): object 'orders' not found
onlineloc=round(onlineloc,digits = 2)
#> Error in eval(expr, envir, enclos): object 'onlineloc' not found
instore=data.frame(lat=runif(orders,29,34),
                   long=runif(orders,69,72))
#> Error in runif(orders, 29, 34): object 'orders' not found
instore=round(instore,digits = 2)
#> Error in eval(expr, envir, enclos): object 'instore' not found
onlineloc%>%
  leaflet() %>%
  addTiles(group = "1") %>%
  addPolylines(lng=~long,lat= ~lat,color = "red",group = "5") %>%
  addMarkers(lat=~lat,lng=~long,popup = "Online Loc",group = "2") 
#> Error in eval(lhs, parent, parent): object 'onlineloc' not found
instore%>%
  leaflet() %>%
  addTiles(group = "3") %>%
  addMarkers(popup = "instore customer",group = "4") %>%
  addPolylines(lng=~long,lat= ~lat,color = "blue",group = "5") %>%
  addLayersControl(
    baseGroups = c("1","2"),
    overlayGroups = c("3","4","5")
  )
#> Error in eval(lhs, parent, parent): object 'instore' not found

Created on 2020-02-05 by the reprex package (v0.3.0)

your second line of code is erroring as you have no orders object is defined.
what do you intend for that to contain ?

that code is correct if i define orders=10, but i need one map not separate maps can you help?

  leaflet() %>%
  addTiles() %>%
  addPolylines(lng=onlineloc$long,lat= onlineloc$lat,color = "red",group = "1") %>%
  addMarkers(lat=onlineloc$lat,lng=onlineloc$long,popup = "Online Loc",group = "1") %>%
  addPolylines(lng=instore$long,lat= instore$lat,color = "blue",group = "2") %>%
  addMarkers(lng=instore$long,lat= instore$lat,popup = "instore customer",group = "2")

my attempt

1 Like

how i can change the colour of marker for instore or onlineloc?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.