Last active
March 22, 2022 09:05
-
-
Save itanka9/935b8c11cb77a04183b70760e6761ada to your computer and use it in GitHub Desktop.
Mapgl Fly Around
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>2GIS Map API</title> | |
| <meta name="description" content="Quckstart with 2GIS Map API"> | |
| <style> | |
| html, | |
| body, | |
| #container { | |
| margin: 0; | |
| width: 100%; | |
| height: 100%; | |
| overflow: hidden; | |
| } | |
| #fly-button { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| z-index: 2; | |
| } | |
| #fly-duration { | |
| position: absolute; | |
| top: 0; | |
| left: 50px; | |
| z-index: 2; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <button id="fly-button" onclick="fly()"> | |
| fly | |
| </button> | |
| <input id="fly-duration" size="8" value="5000"> | |
| <div id="container"></div> | |
| <script src="https://mapgl.2gis.com/api/js/v1"></script> | |
| <script> | |
| const map = new mapgl.Map('container', { | |
| center: [55.31878, 25.23584], | |
| zoom: 13, | |
| key: 'bfd8bbca-8abf-11ea-b033-5fa57aae2de7', | |
| style: 'c080bb6a-8134-4993-93a1-5b4d8c36a59b' | |
| }); | |
| async function fly() { | |
| const durationEl = document.querySelector('#fly-duration'); | |
| const duration = +(durationEl && durationEl.value || 5000); | |
| map.setRotation(360, { normalize: false, duration }); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment