From 46a5d1910b74c938ed8edf9d48fb95c1d1990a19 Mon Sep 17 00:00:00 2001 From: badbye Date: Wed, 24 May 2017 15:26:07 +0800 Subject: [PATCH] msg --- DESCRIPTION | 2 +- R/geoconv.R | 2 +- R/getBaiduMap.R | 9 ++++++++- R/getCoordinate.R | 18 +++++++++--------- R/getLocation.R | 4 ++-- R/getPlace.R | 2 +- R/getRoute.R | 2 +- R/onLoad.R | 10 +++++++--- 8 files changed, 30 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cdcf348..85a9e50 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: baidumap Title: A package for spatial visualization with Baidu -Version: 0.2.1 +Version: 0.2.2 Encoding: UTF-8 Author: yalei Du Maintainer: yalei Du diff --git a/R/geoconv.R b/R/geoconv.R index 010cbdc..d50cef2 100644 --- a/R/geoconv.R +++ b/R/geoconv.R @@ -9,7 +9,7 @@ #' @export geoconv geoconv = function(geocode, from=3, to=5, map_ak=''){ if (map_ak == '' && is.null(getOption('baidumap.key'))){ - stop('Please register AK by ') + stop(Notification) }else{ map_ak = ifelse(map_ak == '', getOption('baidumap.key'), map_ak) } diff --git a/R/getBaiduMap.R b/R/getBaiduMap.R index 49e3db9..4e92d11 100644 --- a/R/getBaiduMap.R +++ b/R/getBaiduMap.R @@ -32,7 +32,14 @@ #' ## do not print messages #' p <- getBaiduMap(messaging = F) #' } -getBaiduMap = function(location, width=400, height = 400, zoom=10, scale=2, color = "color", messaging = TRUE){ +getBaiduMap = function(location, width=400, height = 400, zoom=10, + scale=2, color = "color", messaging = TRUE, + map_ak = ''){ + if (map_ak == '' && is.null(getOption('baidumap.key'))){ + stop(Notification) + }else{ + map_ak = ifelse(map_ak == '', getOption('baidumap.key'), map_ak) + } ## location if (is.character(location) && length(location) == 1){ location_cor = getCoordinate(location, formatted=T) diff --git a/R/getCoordinate.R b/R/getCoordinate.R index 8f7621d..072bcff 100644 --- a/R/getCoordinate.R +++ b/R/getCoordinate.R @@ -1,11 +1,6 @@ getCoordinate.core = function(address, city=NULL, output='json', formatted = F, map_ak = ''){ - if (map_ak == '' && is.null(getOption('baidumap.key'))){ - stop('Please register AK by ') - }else{ - map_ak = ifelse(map_ak == '', getOption('baidumap.key'), map_ak) - } ### address if (any(grepl(' |#', address))) warning('address should not have blank character!') address = gsub(' |#', '', address) @@ -65,19 +60,24 @@ getCoordinate.core = function(address, city=NULL, #' ## vectorization, return a matrix #' getCoordinate(c('北京大学', '清华大学'), formatted = T) #' } -getCoordinate=function(address, city=NULL, output='json', formatted = F,limit=600){ +getCoordinate=function(address, city=NULL, output='json', formatted = F,limit=600, map_ak=''){ + if (map_ak == '' && is.null(getOption('baidumap.key'))){ + stop(Notification) + }else{ + map_ak = ifelse(map_ak == '', getOption('baidumap.key'), map_ak) + } if(length(address)