Bỏ qua

Marker

Marker dùng để đánh dấu một điểm trên bản đồ, thường là các vị trí quan trọng như điểm đến, điểm xuất phát hay nơi diễn ra sự kiện. Marker đổi được giao diện bằng ảnh hoặc icon.

Tạo marker mặc định

Ví dụ này tạo một marker mặc định trên bản đồ.

Ví dụ```html

Add a default marker
Tuỳ chỉnh màu sắc và icon trong [Map Editor](https://tools.vietmap.vn/map-editor/), sau đó thay URL style ở trên bằng link style của bạn.

## Tạo marker với icon PNG riêng
<iframe 
    src="/docs/sdk-web-gl/marker/code-marker/marker-png.html" 
    width="100%" 
    height="450" 
    style="border:0;" 
    allowfullscreen="" 
    loading="lazy">
</iframe>
### Ví dụ```html
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Marker PNG</title>
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  <link rel='stylesheet' href='https://unpkg.com/@vietmap/vietmap-gl-js@6.0.1/dist/vietmap-gl.css' />
  <script src='https://unpkg.com/@vietmap/vietmap-gl-js@6.0.1/dist/vietmap-gl.js'></script>
  <style>
    body {
      margin: 0;
      padding: 0;
    }

    #map {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 100%;
    }
  </style>
</head>

<body>
  <div id="map"></div>
  <script>
    const map = new vietmapgl.Map({
      container: "map",
      style:
        "https://maps.vietmap.vn/maps/styles/tm/style.json?apikey=YOUR_API_KEY_HERE",
      center: [106.66817068179284, 10.803866192772915],
      zoom: 14,
    });
    map.addControl(new vietmapgl.NavigationControl(), "top-right");

    map.on("load", async function () {
      const image = await map.loadImage("/docs/assets/navigator.png");

      map.addImage("vietmap", image.data);
      map.addSource("point", {
        type: "geojson",
        data: {
          type: "FeatureCollection",
          features: [
            {
              type: "Feature",
              geometry: {
                type: "Point",
                coordinates: [106.66817068179284, 10.803866192772915],
              },
            },
          ],
        },
      });
      map.addLayer({
        id: "points",
        type: "symbol",
        source: "point",
        layout: {
          "icon-image": "vietmap",
          "icon-size": 0.75,
          "icon-anchor": "bottom",
          "icon-offset": [0, -10],
        },
      });
    });
  </script>
</body>
</html>

Tạo marker với icon SVG riêng

Ví dụ```html

Test VM-GL

```

Hotline
Tổng đài hỗ trợ
089.616.4567
Messenger Chat Facebook zalo Chat Zalo