|
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport"
- content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
- <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
- <title>Hello APP</title>
- <link rel="stylesheet" type="text/css" href="../css/api.css" />
- <style>
- label {
- margin: 10px;
- font-size: 24px;
- }
- ul {
- margin-bottom: 10px;
- }
- ul li {
- margin: 5px 10px;
- padding: 5px;
- color: #000;
- word-wrap: break-word;
- }
- </style>
- </head>
- <body>
- <button type="button" onclick="test()">Click Me!</button>
- </body>
- <script type="text/javascript" src="../script/api.js"></script>
- <script type="text/javascript">
- apiready = function () {
- var map = api.require('bMap');
- map.setAgreePrivacy({
- agree: true
- });
- map.initMapSDK(function (ret) {
- if (ret.status) {
- alert('地图初始化成功,可以从百度地图服务器检索信息了!');
- map.open({
- rect: {
- x: 0,
- y: 0,
- w: 320,
- h: 300
- },
- center: {
- lon: 116.4021310000,
- lat: 39.9994480000
- },
- zoomLevel: 10,
- showUserLocation: true,
- fixedOn: api.frameName,
- fixed: true
- }, function (ret) {
- if (ret.status) {
- alert('地图打开成功');
- }
- map.searchDistrict({
- id: '123456',
- city: '南充市',
- style: {
- fillColor: '#f5f5f5f',
- strokeColor: '#3870FF',
- lineWidth: 3
- }
- }, function (ret, err) {
- });
- });
- }
- });
- };
- </script>
- </html>
复制代码 |
|