百度地图api通过地址显示地图,白名单
http://developer.baidu.com/map/jsdemo.htm#i7_1?qq-pf-to=pcqq.c2c
------------------------------------
【百度地图API】如何进行地址解析与反地址解析?——模糊地址能搜索到精确地理信息! - 酸奶小妹 - 博客园
http://www.cnblogs.com/milkmap/archive/2011/05/27/2059833.html
===========================================
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=申请的添加到白名单域名的apikey"></script>
<script type="text/javascript">
var map = new BMap.Map("allmap");
//创建地址解析器实例
var myGeo = new BMap.Geocoder();
// 将地址解析结果显示在地图上,并调整地图视野
myGeo.getPoint("深南大道益田假日广场", function(point){
if (point) {
map.centerAndZoom(point, 16);
map.addOverlay(new BMap.Marker(point));
}else{
alert("您选择地址没有解析到结果!");
}
}, "深圳市");
</script>
===========================================
var map = new BMap.Map("allmap");
// 创建地址解析器实例
var myGeo = new BMap.Geocoder();
// 将地址解析结果显示在地图上,并调整地图视野
myGeo.getPoint("北京市海淀区上地10街", function(point){
if (point) {
map.centerAndZoom(point, 16);
map.addOverlay(new BMap.Marker(point));
}
}, "北京市");
==========================================
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=申请的apikey"></script>
<title>地址解析</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
// 百度地图API功能
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.331398,39.897445);
map.centerAndZoom(point,12);
// 创建地址解析器实例
var myGeo = new BMap.Geocoder();
// 将地址解析结果显示在地图上,并调整地图视野
myGeo.getPoint("北京市海淀区上地10街", function(point){
if (point) {
map.centerAndZoom(point, 16);
map.addOverlay(new BMap.Marker(point));
}else{
alert("您选择地址没有解析到结果!");
}
}, "北京市");
</script>
====================================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>地址解析+反地址解析</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
</head>
<body>
<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
<div style="margin:10px 0;"><input type="text" style="width:300px;margin-right:10px;" value="新华路" id="searchValue" /><input type="button" value="搜索" onclick="search()" /></div>
</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("container");
map.centerAndZoom(new BMap.Point(121.461165,31.234095), 11);
function search(){
var myAddress = document.getElementById('searchValue').value;
var myGeo = new BMap.Geocoder();
myGeo.getPoint(myAddress, function(point){ //我输入的是“知春路”,第一步getPoint是地址解析。
if (point) {
map.centerAndZoom(point, 16);
map.addOverlay(new BMap.Marker(point));
myGeo.getLocation(point, function(rs){ //这里弹出“知春路”的详细地址信息,第二步getLocation是反地址解析。
var addComp = rs.addressComponents;
alert(myAddress+'的具体位置是:'+addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
});
}
}, "上海市"); //必须设置城市
}
</script>