This complete example displays a movable and zoomable map, embedded inside an html element on a webpage.
The interactive map is centered on a desired initial location which is defined as a point using a (longitude, latitude) coordinate pair with altitude in meters.
The map supports pan and zoom, and is fully 3D, so holding down the shift key and panning will simultaneously rotate and tilt the map.
Or you can continue reading for a detailed explanation of the code.
How it works¶
canvasis the drawing area where the map is rendered. The canvas is configured to fill the browser window.Note that the
The example is 2 plain text files, one with the HTML code (
To run the example, the HTML file is loaded in a browser. The
.jsfile should be in the same directory, as it will be loaded automatically.
right-click on the links and select Save As.