Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (44 sloc) 2.42 KB
<!DOCTYPE html>
<html>
<head>
<title>Azure Maps Raster Tiles in Leaflet JS - Azure Maps Web SDK Samples</title>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="This sample shows how to render Azure Maps Raster Tiles in the Leaflet JS map control." />
<meta name="keywords" content="map, gis, API, SDK, tiles, raster, leaflet, leaflet.js" />
<meta name="author" content="Microsoft Azure Maps" />
<!-- Add references to the Leaflet JS map control resources. -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin="" />
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin=""></script>
<script type='text/javascript'>
var map;
function GetMap() {
map = L.map('myMap').setView([0, 0], 2);
//Create a tile layer that points to the Azure Maps tiles.
L.tileLayer('https://atlas.microsoft.com/map/tile/png?api-version=1&layer=basic&style=main&tileSize=512&view=Auto&zoom={z}&x={x}&y={y}&subscription-key={subscriptionKey}', {
attribution: `© ${new Date().getFullYear()} TomTom, Microsoft`,
maxZoom: 22,
tileSize: 512,
zoomOffset: -1,
id: 'azuremaps.road',
crossOrigin: true,
subscriptionKey: '<Your Azure Maps Key>'
//Add your Azure Maps subscription key to the map SDK. Get an Azure Maps key at https://azure.com/maps
}).addTo(map);
}
</script>
</head>
<body onload="GetMap()">
<div id="myMap" style="position:relative;width:100%;min-width:290px;height:600px;"></div>
<fieldset style="width:calc(100% - 30px);min-width:290px;margin-top:10px;">
<legend>Raster Tiles in Leaflet JS</legend>
This sample shows how to render Azure Maps Raster Tiles in the <a href="http://leafletjs.com/">Leaflet JS map control</a>. <br/>
Tip: Use 512 tiles instead of 256 tiles as it generates 1/4th the tile requests.
</fieldset>
</body>
</html>
You can’t perform that action at this time.