Skip to content
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (56 sloc) 3.13 KB
<!DOCTYPE html>
<html>
<head>
<title>Simple MultiPolygon - 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 a MultiPolygon on the map." />
<meta name="keywords" content="map, gis, API, SDK, polyon, multipolygon" />
<meta name="author" content="Microsoft Azure Maps" />
<!-- Add references to the Azure Maps Map control JavaScript and CSS files. -->
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css" />
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
<script type='text/javascript'>
var map, datasource;
function GetMap() {
//Initialize a map instance.
map = new atlas.Map('myMap', {
center: [-122.125, 47.6295],
zoom: 16,
style: 'grayscale_dark',
view: 'Auto',
//Add your Azure Maps subscription key to the map SDK. Get an Azure Maps key at https://azure.com/maps
authOptions: {
authType: 'subscriptionKey',
subscriptionKey: '<Your Azure Maps Key>'
}
});
//Wait until the map resources are ready.
map.events.add('ready', function () {
//Create a data source and add it to the map.
datasource = new atlas.source.DataSource();
map.sources.add(datasource);
//Add polygon to data source.
datasource.add(new atlas.data.MultiPolygon([
[[[-122.126, 47.63096], [-122.12602, 47.62997], [-122.12537, 47.62994], [-122.12534, 47.63094], [-122.12600, 47.63096]]],
[[[-122.12497, 47.63098], [-122.12497, 47.63065], [-122.12450, 47.63044], [-122.12415, 47.63037], [-122.12418, 47.63098], [-122.12497, 47.63098]]],
[[[-122.12636, 47.62813], [-122.12527, 47.62859], [-122.12562, 47.62906], [-122.12596, 47.62919], [-122.12619, 47.62919], [-122.12690, 47.62899], [-122.12636, 47.62813]]],
[[[-122.12494, 47.62825], [-122.12494, 47.62792], [-122.12354, 47.62788], [-122.12351, 47.62823], [-122.12494, 47.62825]]]
]));
//Create a layer to render the polygon data and add it to the map.
map.layers.add(new atlas.layer.PolygonLayer(datasource, null, {
fillColor: 'rgba(0, 200, 200, 0.5)'
}));
});
}
</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>Simple MultiPolygon</legend>
This sample shows how to render a MultiPolygon on the map. In this case the MultiPolygon represents a collection of playing fields at a school.
</fieldset>
</body>
</html>
You can’t perform that action at this time.