先说第一种,最早应该是从maps包开始的,这个包里没记错的话应该用map函数为主,
>map("world", fill = TRUE, col = rainbow(200),ylim = c(-90, 90), mar = c(0, 2, 0, 0))
>title("worldmap")
这种用法大家应该很熟了,比较可惜的是里面的数据是在是太少了,连张中国地图都画不了,好在后来有了mapdata等一系列的包,CRAN上maps包后面那一串全是。
具体的内容看一下文档就ok啦,可是问题又来了,R包里的数据总是不够用的,而且还不新,这个时候就可以考虑sp包了,包里的spplot函数可以用来画地图
可以用ggmap包中的geocode函数,比如geocode("tiananmen")/**
* 根据地址返回经纬度
* @param addr
* @return 返回经纬度数据, latLng[0]经度,latLng[1]维度
*/
public static String[] getCoordinate(String addr) {
String[] latLng = new String[2]
String address = null
try {
address = java.net.URLEncoder.encode(addr, "UTF-8")
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace()
}
String output = "csv"
//密钥可以随便写一个key=abc
String key = "abc"
String url = "http://maps.google.com/maps/geo?q=" + address + "&output=" + output + "&key=" + key
URL googleMapURL = null
URLConnection httpsConn = null
// 进行转码
try {
googleMapURL = new URL(url)
} catch (MalformedURLException e) {
e.printStackTrace()
}
try {
httpsConn = (URLConnection)googleMapURL.openConnection()
if (httpsConn != null) {
InputStreamReader insr = new InputStreamReader(httpsConn.getInputStream(), "UTF-8")
BufferedReader br = new BufferedReader(insr)
String data = null
if ((data = br.readLine()) != null) {
String[] retList = data.split(",")
/*
* String latitude = retList[2]String longitude =
* retList[3]
*
* System.out.println("纬度"+ latitude)
* System.out.println("经度"+ longitude)
*/
if (retList.length >2 &&("200".equals(retList[0]))) {
latLng[0] = retList[2]
latLng[1] = retList[3]
}
}
insr.close()
}
} catch (IOException e) {
e.printStackTrace()
}
return latLng
}
1、谷歌地图不支持语言更换功能,但用户可以搜索本国的软件版本,下载安装后即可显示本国语言。2、
3、谷歌地图是Google公司提供的电子地图服务,包括局部详细的卫星照片。此款服务可以提供含有全球城市政区和交通以及商业信息的矢量地图、不同分辨率的卫星照片和可以用来显示地形和等高线地形视图。在2014年3月5日谷歌表示印度22个城市的用户已经可以访问谷歌地图中75个在当地比较流行的室内场地地图,包括位于古尔冈的AmbienceMall,以及德里的SelectCityWalk购物中心等。
4、
5、