1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <style> #container { width: 1280px; height: 720px; } </style> </head> <body> <div id="container"></div> <script src="https://webapi.amap.com/loader.js"></script> <script type="text/javascript"> window._AMapSecurityConfig = { securityJsCode: "9f9d9391b3ba92237652b8a93fe47d96", }; AMapLoader.load({ key: "f843b51e9bc03fe1f14969aa27e78449", version: "2.0", AMapUI: { version: "1.1", plugins: ["overlay/SimpleMarker"], }, }) .then((AMap) => { AMapUI.load( ["ui/misc/PathSimplifier", "lib/$"], function (PathSimplifier, $) { const gps = [116.478935, 39.997761]; const path_data = [ { name: "轨迹巡航", path: [ [116.478935, 39.997761], [116.478939, 39.997825], [116.478912, 39.998549], [116.478912, 39.998549], [116.478998, 39.998555], [116.478998, 39.998555], [116.479282, 39.99856], [116.479658, 39.998528], [116.480151, 39.998453], [116.480784, 39.998302], [116.480784, 39.998302], [116.481149, 39.998184], [116.481573, 39.997997], [116.481863, 39.997846], [116.482072, 39.997718], [116.482362, 39.997718], [116.483633, 39.998935], [116.48367, 39.998968], [116.484648, 39.999861], ], }, ];
const map = new AMap.Map("container", { center: gps, zoom: 17, });
const pathSimplifierIns = new PathSimplifier({ map: map, autoSetFitView: false, getPath: function (pathData, pathIndex) { return pathData.path; }, renderOptions: { pathNavigatorStyle: { width: 26, height: 52, content: PathSimplifier.Render.Canvas.getImageContent( "https://a.amap.com/jsapi_demos/static/demo-center-v2/car.png" ), pathLinePassedStyle: { strokeStyle: "#00000000", borderStyle: "#00000000", }, }, getPathStyle: function (pathItem, zoom) { return { pathLineStyle: { strokeStyle: "#00000000", borderStyle: "#00000000", }, startPointStyle: { fillStyle: "", strokeStyle: "", }, endPointStyle: { fillStyle: "", strokeStyle: "", }, }; }, }, }); pathSimplifierIns.setData(path_data);
const navg = pathSimplifierIns.createPathNavigator(0, { loop: true, speed: 120, }); navg.start(); } ); }) .catch((e) => { console.error(e); }); </script> </body> </html>
|