library('mapmisc', quietly=TRUE)
haveRgdal = requireNamespace('rgdal', quietly=TRUE)
haveGeosphere = requireNamespace('geosphere', quietly=TRUE)

if(!exists('mapmiscCachePath'))
  mapmiscCachePath = system.file('extdata', package='mapmisc')

if(!exists('mapmiscCacheReadOnly'))
  mapmiscCacheReadOnly = TRUE

if(!exists('testing'))
  testing=FALSE

if(!exists('fact'))
  fact = 0.6
# uncomment for nicer images
# fact = 1 

options(
  mapmiscCachePath = mapmiscCachePath,
  mapmiscCacheReadOnly = mapmiscCacheReadOnly
  )
okinawa = mapmisc::geocode("Okinawa")
hk = y = mapmisc::geocode("Hong Kong")
guam = mapmisc::geocode("Guam")
x = SpatialPoints(cbind(130,15), proj4string=crsLL)
if(haveGeosphere & haveRgdal) {
  myProj = tpers(x=bind(x,y), hKm = 2*1000,
      tilt =-15, axis='seu')
  xProj = spTransform(guam, myProj)
  yProj = spTransform(hk, myProj)
  okinawaProj = spTransform(okinawa, myProj)
}
if(haveGeosphere & haveRgdal)
  myMap = openmap(myProj, path='landscape', zoom=2,fact=3)
## Warning in rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, :
## 489 projected point(s) not finite

## Warning in rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, :
## 489 projected point(s) not finite
## Warning in rgdal::rawTransform(projto_int, projfrom, nrow(xy), xy[, 1], :
## 249044 projected point(s) not finite
if(haveGeosphere & haveRgdal) {
  map.new(myProj, bg='black', buffer=2*100*1000)
  plot(myMap, add=TRUE)

  if(requireNamespace('maptools')) {
    data("wrld_simpl", package='maptools')
    wrld4 = wrapPoly(x=wrld_simpl, crs=myProj)
    plot(wrld4, add=TRUE)
  }

  gridlinesWrap(myProj, col='yellow', 
      north=seq(-40,40,by=10), easts=seq(-150,180,by=10),
      lty=2)

  points(xProj, col='red', pch=16, cex=2)
  text(xProj@coords, 
      as.character(xProj$originalPlace),
      pos=2, col='red')

  points(okinawaProj, col='red', pch=16, cex=2)
  text(okinawaProj@coords, 
      as.character(okinawaProj$originalPlace),
      pos=2, col='red')

  points(yProj, col='red', pch=16, cex=2)
  text(yProj@coords, 
      as.character(yProj$originalPlace),
      pos=2, col='red')

}
## Loading required namespace: maptools

plot of chunk map

h