<!-- * @Author: 一只小菜鸡 y1286780926@163.com * @Date: 2022-11-16 10:50:15 * @LastEditors: 一只小菜鸡 y1286780926@163.com * @LastEditTime: 2023-01-31 16:19:02 * @FilePath: \map-gl\base\百度地图.html * @Description: * * Copyright (c) 2022 by bigemap/一只小菜鸡 y1286780926@163.com, All Rights Reserved. --> <!DOCTYPE html> <html> <head> <meta charset='UTF-8' /> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <link href='http://www.bigemap.com:9000/bigemap-gl.js/v1.1.0/Widgets/widgets.css' rel='stylesheet' /> <script src='http://www.bigemap.com:9000/bigemap-gl.js/v1.1.0/bigemap-gl.js'></script> <script src="http://www.bigemap.com/public/js/baidusupport.min.js"></script> <style> body { margin: 0; padding: 0; } #container { position: absolute; top: 0; bottom: 0; width: 100%; } </style> <title>中国卫图(GE)</title> </head> <body> <div id='container'></div> <script> var ip = 'http://www.bigemap.com:9000'; bmgl.Config.HTTP_URL = ip; var mapid = 'bigemap.baidu-map'; var viewer = new bmgl.Viewer('container'); var promise = fetch(`${ip}/tokens/v1?access_token=none`).then(function (response) { return response.json(); }).then(function (body) { return body.token }).then( (token) => { return fetch(`${ip}/v2/${mapid}.json?access_token=${token}`).then(function (response) { return response.json(); }).then((body) => { url = body.tiles[0]; let layer = new bmgl.ImageryLayer(new bmgl.BaiduImageryProvider({ url: url })); viewer.imageryLayers.remove(viewer.imageryLayers.get(0), false); viewer.imageryLayers.add(layer); return url }) } ) </script> </body> </html>
源码