gengaixue

百度地图 城市切换

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script>
    <title>23.1 城市切换</title>
</head>
<body>
    <div class="wrapper">      
    <p>我要去<input id="txtSearch" type="text" value="上海"/><input type="button" value="GO" onclick="search()"/></p>  
        <div class="container clearfix">
            <div class="clearfix">
                <div style="clear: both;">
                    <div style="float: left; width: 500px; height: 340px; border: 1px solid gray" id="container">
                    </div>                    
                </div>
            </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("container");
    map.centerAndZoom(new BMap.Point(116.404, 39.915), 16);

    var city = new BMap.LocalSearch(map, {
        renderOptions: {
            map: map,
            autoViewport:true
        }
    });

    function search() {
        var s = document.getElementById("txtSearch").value;
        city.search(s);
    }
</script>

分类:

技术点:

相关文章:

  • 2021-11-17
  • 2021-06-27
  • 2022-02-07
  • 2022-01-20
  • 2021-12-23
  • 2021-11-17
  • 2021-12-17
猜你喜欢
  • 2021-12-03
  • 2021-09-16
  • 2021-11-14
  • 2022-01-14
  • 2021-09-13
  • 2021-11-12
相关资源
相似解决方案