set_projection: Set projection

Description Usage Arguments Note See Also Examples

View source: R/opts.R

Description

Set projection

Usage

1
set_projection(p, fun = htmlwidgets::JS())

Arguments

p

a datamaps object.

fun

a JavaScript function.

Note

Does not work in RStudio viewer, open in browser.

See Also

https://github.com/Anujarya300/bubble_maps

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
topo <- paste0("https://rawgit.com/Anujarya300/bubble_maps/",
  "master/data/geography-data/india.topo.json")
  
data <- data.frame(state = c("JH", "MH"), value = c(55, 28))
  
data %>% 
  datamaps(scope = "india") %>% 
  add_choropleth(state, value) %>% 
  config_geo(data.url = topo) %>% 
  set_projection(htmlwidgets::JS('
  function (element) {
    var projection = d3.geo.mercator()
    .center([78.9629, 23.5937])
    .scale(1000);
    var path = d3.geo.path().projection(projection);
    return { path: path, projection: projection };
  }
  ')
  )

JohnCoene/datamaps documentation built on May 17, 2018, 12:17 p.m.