码迷,mamicode.com
首页 > Windows程序 > 详细

百度地图api实例

时间:2015-07-10 10:49:50      阅读:428      评论:0      收藏:0      [点我收藏+]

标签:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm11.aspx.cs" Inherits="JQGridExercise.WebForm11" %>

<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{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";font-size:14px;}
#allmap {width:100%;height:500px;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=63i90lOgvKon1KU0AnLGgGkC"></script>
<title>逆地址解析</title>
</head>
<body>
<div id="allmap" style="width:1200px;height:600px;"></div>
<p>点击地图展示详细地址</p>
</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);
map.enableScrollWheelZoom(true);
var geoc = new BMap.Geocoder();
map.addControl(new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_RIGHT, offset: new BMap.Size(40, 60) })); // 添加平移缩放控件
var pointArray = new Array();
map.addEventListener("click", function (e) {
var pt = e.point;
var pointArray = new Array();
var marker = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat)); // 创建点
map.addOverlay(marker); //增加点
pointArray[0] = new BMap.Point(e.point.lng, e.point.lat);
//marker.addEventListener("click", attribute);


geoc.getLocation(pt, function (rs) {

var addComp = rs.addressComponents;
//alert(e.point.lng + ", " + e.point.lat);
alert(rs.address);
});
});
</script>

百度地图api实例

标签:

原文地址:http://www.cnblogs.com/honghong75042/p/4634894.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!