1.0.16 • Published 4 months ago

arrow-map v1.0.16

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

Arrow 海图 SDK

基于 Leaflet 构建的地图 SDK

接口介绍

  1. 初始化
const map = new MyMap("map");
  1. 绘制船舶 drawShips
map.drawShips([
    {
      mmsi: "1120154506",
      label: "神华506",
      lng: 121.705,
      lat: 31.3,
      course: 45,
      updatetime: "2024-5-31",
      width: 60,
      length: 110,
    },
  ]);
  1. 绘制轨迹线 drawTrajectory
map.drawTrajectory([
  { lat: 31.254086, lng: 121.742848, ts: "2024-7-19 15:32:41" },
  { lat: 31.254086, lng: 121.743048, ts: "2024-7-19 16:00:41" },
  { lat: 31.35, lng: 121.805, ts: "2024-7-20 16:32:41" },
  { lat: 31.37, lng: 121.835, ts: "2024-7-21 18:32:41" },
  { lat: 31.4, lng: 121.9, ts: "2024-7-22 15:32:41" },
])
  1. 播放轨迹动画 playAnimatedMarker
 map.playAnimatedMarker(
    {
      points: historyLines,
      totalDuration: 10000,
    },
    {
      iconSize: [38, 26],
      iconAnchor: [19, 13],
      iconUrl: icon,
    },
    null, // 每帧动画渲染的回调
    () => {
      // 动画结束
    }
  );
  1. 暂停轨迹动画 pauseAnimatedMarker
 map.pauseAnimatedMarker(true);
  1. 绘制靠泊点 drawPointMarkers
 map.drawPointMarkers([
    {
      lat: 31.374086,
      lng: 121.732848,
      text: "2024-7-19 15:32:41",
      icon: stop1Png,
    },
    { lat: 31.36, lng: 121.805, text: "2024-7-20 15:32:41", icon: stop2Png },
  ]);
  1. 绘制 HTML 浮层drawHtmlOverlay
map.drawHtmlOverlay(
    [31.28, 121.75],
    `<div class="layer"><div class="name">神华536</div><img width="36" height="36" src="${wavePng}" class="bg" /><div class="triangle"></div></div>`
  );
  1. 创建聚合 Marker createMarkerClusterer
  map
    .createMarkerClusterer(
      (o) => {
        // 错位布局时html模板
        return `<div
          class="marker"
          style='
            transform: translateX(${
              o.reverse ? "calc(-50% + 14px)" : "calc(50% - 14px)"
            });
            flex-direction: ${o.reverse ? "row-reverse" : "row"}
          '
        >
          <img width='24px' src="${iconPng}" />
          <div class="label" style='flexDirection: ${
            o.reverse ? "row-reverse" : "row"
          }'>
            <div>${o.key}</div>
          </div>
        </div>`;
    })
    .markerClustererSetData(source);
  1. 绘制原生标记点 drawMarker
    默认蓝色图标
map.drawMarker({ lat: 31.3, lng: 121.75 });
  1. 绘制原生折线 drawPolyline
map.drawPolyline([{ lat: 31.3, lng: 121.75 },{ lat: 31.4, lng: 121.75 }]);
  1. 绘制原生多边形 drawPolygon
map.drawPolygon([{ lat: 31.3, lng: 121.75 },{ lat: 31.4, lng: 121.75 },{ lat: 31.5, lng: 121.75 }]);
  1. 加载折线 newDrawPolyline
 const c = _map.newDrawPolyline(({ id, latLngs, remove }) => {
  });
  c.setData({
    id: "8e6d6c35-cecb-4a37-9833-773e7b143151",
    latLngs: [
      {
        lat: 31.252139190566062,
        lng: 122.28332519531251,
      },
      {
        lat: 31.392329799557228,
        lng: 122.29293823242189,
      },
      {
        lat: 31.400049579500894,
        lng: 122.13741618147185,
      },
      {
        lat: 31.259859656828837,
        lng: 122.12803347785064,
      },
    ],
  });
  1. 绘制多边形 newDrawPolygon
 const c = map.newDrawPolygon(({ id, latLngs, remove }) => {
  });
  c.openDraw();
  1. 开启测量 startDrawMeasure
    双击选中图形,Delete 键删除
map.startDrawMeasure();
  1. 销毁 destory
map.destory()
1.0.16

4 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.0.23

8 months ago

0.0.24

8 months ago

0.0.25

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.11

8 months ago

0.0.9

8 months ago

0.0.26

8 months ago

1.0.10

8 months ago

0.0.20

8 months ago

0.0.21

8 months ago

0.0.22

8 months ago

0.0.19

8 months ago

0.0.18

9 months ago

0.0.13

9 months ago

0.0.14

9 months ago

0.0.15

9 months ago

0.0.16

9 months ago

0.0.17

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.8

10 months ago

0.0.5

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago