zoukankan      html  css  js  c++  java
  • 百度地图api实例

    <%@ 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{ 100%;height: 100%;margin:0;font-family:"微软雅黑";font-size:14px;}
    #allmap {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="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>

  • 相关阅读:
    Java实现 LeetCode 730 统计不同回文子字符串(动态规划)
    Python long() 函数
    Python int() 函数
    Python 变量类型
    Python 基础语法
    Python 中文编码
    深度学习点云语义分割:CVPR2019论文阅读
    自动泊车技术短暂困境,前景可期
    深度学习网络模型压缩剪枝详细分析
    用OpenCV4实现图像的超分别率
  • 原文地址:https://www.cnblogs.com/honghong75042/p/4634894.html
Copyright © 2011-2022 走看看