Baidu map positioning (1)

1. Reprint

<!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 src="http://api.map.baidu.com/api?v=1.4&ak=您的密钥"></script>
    <title>地图展示</title>
</head>
<body>
    <div id="allmap"></div>
</body>
</html>
<script type="text/javascript">     var map = new BMap.Map("allmap"); // Create a Map instance
    // Baidu Map API function

    map.centerAndZoom(new BMap.Point(121.272291,31.202356), 22); // Initialize the map, set the center point coordinates and map levels 1 to 22
    //Add map type controls
    map.addControl(new BMap.MapTypeControl({
        mapTypes :[
            BMAP_NORMAL_MAP,
            BMAP_HYBRID_MAP
        ]}));      
    map.setCurrentCity("Shanghai"); // Set the city displayed on the map. This item must be set
    map.enableScrollWheelZoom(true); //Enable mouse wheel zoom
</script>

2. Legend

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325560096&siteId=291194637