php 实现百度地图(很详细出来的地图)

本文介绍了一个使用百度地图API的应用实例,通过一段简单的HTML和JavaScript代码实现了地图展示及地点搜索功能。该示例展示了如何加载百度地图API,设置地图的基本属性如位置与缩放级别,并进行本地搜索。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<pre name="code" class="php"><html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>百度地图搜索--leyangjun</title>
        <script type="text/javascript" src="http://api.map.baidu.com/api?key=46ce9d0614bf7aefe0ba562f8cf87194&v=1.2&services=true"></script>
    </head>
    <body>
        <div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
        <div id="results" style="font-size:13px;margin-top:10px;"></div>
    </body>
</html>
<script type="text/javascript">

    var map = new BMap.Map("container");
    map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
    var local = new BMap.LocalSearch(map, {
        renderOptions: {map: map, panel: "results"}
    });
    var opts = {anchor: BMAP_ANCHOR_TOP_RIGHT, offset: map.getCenter()};
    //var opts = {anchor: BMAP_ANCHOR_TOP_RIGHT, offset: new BMap.Size(10, 10)};
    map.addControl(new BMap.NavigationControl(opts));
    local.search("北京市海淀区上地地铁站");
</script>




                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值