谁用过google map api???? 我想做一个地图查询,想直接调用google map api,但是不知道它能不能满足我的要求,我需要有中国的完整地图,包括港、澳、台,然后点到省的时候,就标出市一级的城市出来、再到市、就会出来县。然后我不需要其它的地标,只需要我想要的地标,大概在某个位置上就行了,然后点到它的时候,可以出来具体的内容。这样可以做到吗????? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以的..google api :http://code.google.com/intl/en/apis/ajaxsearch/documentation/reference.html String key = "XXXXXXX"; // String output = "JSON"; String output = "xml"; Document document = null;String address = "changsha"; try { String urlpath = "http://maps.google.com/maps/geo?output=" + output + "&key=" + key + "&q=" + URLEncoder.encode(address, "UTF-8"); URL url = new URL((urlpath)); SAXReader reader = new SAXReader(); document = reader.read(new InputStreamReader(url.openStream())); } catch (Exception e) { throw new LutherslistException(e, "Get location failed."); } Element root = document.getRootElement(); System.out.println(root.asXML()); List<Element> list = root.element("Response").elements("Place");然后解析xml 就可以了.... 当然还支持json 操作的. 你需要知道到经纬度,google是通过这个定位的。 还没找到啊,给你一个参考:存为html文件<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAAo07eA8IJ1Wof9febizJTRSqlJ1UWL_pe0SJD0tF2XORmmD5nhTo6VGitXjGGI5Xp0wGAHMt41e0oQ"></script></head><body><div id="singleMap" style="width:document.body.clientWidth; height: 700px"></div><script type="text/javascript"> //解析参数 var map; var geocoder; var latlng; var longitude = 112.123456;//经度 var latitude = 29.234567;//纬度 map = new GMap2(document.getElementById("singleMap")); latlng = new GLatLng(latitude,longitude); map.setCenter(latlng, 11); map.setUIToDefault(); er = new GMarker(latlng); map.addOverlay(er); geocoder = new GClientGeocoder(); GEvent.addListener(er, "click", getAddress); function getAddress(er,latlng) {// if (latlng != null) { latlng = map.getCenter(); address = latlng; geocoder.getLocations(latlng, showAddress);// } } function showAddress(response) { if (!response || response.Status.code != 200) { alert("Status Code:" + response.Status.code); } else { place = response.Place[0]; er.openInfoWindowHtml( '<b>原纬经度: </b>' + response.name + '<br/>' + '<b>纬度经度: </b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' + '<b>具体地址: </b>' + place.address + '<br>' + '<b>分 辨 率: </b>' + place.AddressDetails.Accuracy + " 米"+'<br>' + '<b>国家代码: </b> ' + place.AddressDetails.Country.CountryNameCode); } } </script></body></html> 我看GOOGLE好像会把所有的地方都显示出来,如果只显示我想显示的地方,这样可以的吗???? eclipse启动错误 华为开发平台 表单提交后,我刷新页面,又会提交一次,怎么解决这个问题啊 请问该如何设置,使得打开tomcat时能够浏览一个目录? 急问:利用oracle XDK访问oracle数据库的问题 连接超时 我没分了,麻烦前辈做一下做下作业题,谢谢了 做一个电子商务,需要对多个字段做查询统计。题目见一楼,请指教! 兄弟们,救命啊!!!!!!! 请教jsp高手如何实现类似于includ的功能把一段代码引入?高分相赠!!!!!! hibernate中查询速度问题 求一HQL语句(急!!!)
String key = "XXXXXXX";
// String output = "JSON";
String output = "xml";
Document document = null;
String address = "changsha";
try {
String urlpath = "http://maps.google.com/maps/geo?output=" + output
+ "&key=" + key + "&q="
+ URLEncoder.encode(address, "UTF-8");
URL url = new URL((urlpath));
SAXReader reader = new SAXReader();
document = reader.read(new InputStreamReader(url.openStream()));
} catch (Exception e) {
throw new LutherslistException(e, "Get location failed.");
}
Element root = document.getRootElement();
System.out.println(root.asXML());
List<Element> list = root.element("Response").elements("Place");
然后解析xml 就可以了....
当然还支持json 操作的.
存为html文件<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAAo07eA8IJ1Wof9febizJTRSqlJ1UWL_pe0SJD0tF2XORmmD5nhTo6VGitXjGGI5Xp0wGAHMt41e0oQ"></script>
</head>
<body>
<div id="singleMap" style="width:document.body.clientWidth; height: 700px"></div>
<script type="text/javascript">
//解析参数 var map;
var geocoder;
var latlng;
var longitude = 112.123456;//经度
var latitude = 29.234567;//纬度
map = new GMap2(document.getElementById("singleMap"));
latlng = new GLatLng(latitude,longitude);
map.setCenter(latlng, 11);
map.setUIToDefault();
er = new GMarker(latlng);
map.addOverlay(er);
geocoder = new GClientGeocoder();
GEvent.addListener(er, "click", getAddress);
function getAddress(er,latlng) {
// if (latlng != null) {
latlng = map.getCenter();
address = latlng;
geocoder.getLocations(latlng, showAddress);
// }
} function showAddress(response) {
if (!response || response.Status.code != 200) {
alert("Status Code:" + response.Status.code);
} else {
place = response.Place[0];
er.openInfoWindowHtml(
'<b>原纬经度: </b>' + response.name + '<br/>' +
'<b>纬度经度: </b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
'<b>具体地址: </b>' + place.address + '<br>' +
'<b>分 辨 率: </b>' + place.AddressDetails.Accuracy + " 米"+'<br>' +
'<b>国家代码: </b> ' + place.AddressDetails.Country.CountryNameCode);
}
}
</script></body>
</html>