Skip to content

Газрын зураг PNG-ээр ​

Газрын зургийг нэг хаягаар PNG зураг болгоно: скрипт ажилладаггүй имэйл, захиалгын хуудас, чатад. Зураг газрын зургийг дагана, голдоо тэмдэгтэй.

↗

Код ​

html
<!doctype html>
<html lang="mn">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Static image</title>
<link href="https://dock.mn/sdk/v1/dock.css" rel="stylesheet">
<script src="https://dock.mn/sdk/v1/dock.js"></script>
<style>
  body { margin: 0; font: 14px system-ui, sans-serif; }
  #map { position: absolute; inset: 0; }
  .panel { position: absolute; top: 10px; left: 10px; z-index: 1; width: 300px; padding: 8px 10px;
    background: #fff; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }
  .panel img { display: block; width: 300px; height: 200px; margin-top: 6px; background: #eee; }
</style>
</head>
<body>
<div id="map"></div>
<div class="panel" id="pic">Энэ харагдаж буй газар нэг PNG зураг болж, имэйл эсвэл захиалгын хуудсанд орно.<img alt=""></div>
<script>
  const client = new dock.Client({ key: 'dk_...' });
  const map = dock.createMap(client, { container: 'map', center: [106.9176, 47.9210], zoom: 16 });
  // The picture follows the map: the same place, zoom and turn, a pin in the middle.
  const draw = () => {
    const c = map.getCenter();
    document.querySelector('#pic img').src = dock.staticUrl(client, {
      center: [c.lng, c.lat], zoom: map.getZoom(), bearing: map.getBearing(),
      width: 300, height: 200, retina: true, pins: [[c.lng, c.lat]],
    });
  };
  map.on('load', draw);
  map.on('moveend', draw);
</script>
</body>
</html>