Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
254 lines (213 sloc) 9.79 KB
<!DOCTYPE html>
<html lang="en">
<title>Simple data layer options - 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 the different options of the simple data layer affect rendering." />
<meta name="keywords" content="Microsoft maps, map, gis, API, SDK, line, linestring, polyline, layer, linelayer, symbols, markers, pins, pushpins, spatial data, spatial io module" />
<meta name="author" content="Microsoft Azure Maps" />
<!-- Add references to the Azure Maps Map control JavaScript and CSS files. -->
<link rel="stylesheet" href="" type="text/css" />
<script src=""></script>
<!-- Add reference to the Azure Maps Spatial IO module. -->
<script src=""></script>
<script src="../Common/scripts/clipboard.min.js"></script>
<script type='text/javascript'>
var map, datasource, layer, defaultOptions, removeDefaults;
function GetMap() {
//Point the Azure Maps domain to the US Azure Gov Cloud domain.
//Initialize a map instance.
map = new atlas.Map('myMap', {
center: [-90, 40],
zoom: 2,
pitch: 20,
view: 'Auto',
//Add your Azure Maps subscription key to the map SDK. Get an Azure Maps key at
authOptions: {
authType: 'subscriptionKey',
subscriptionKey: '<Your Azure Maps Key>'
//Wait until the map resources are ready.'ready', function () {
//Create a style control and add it to the map.
new atlas.control.StyleControl({
style: 'dark',
mapStyles: 'all'
new atlas.control.PitchControl({
style: 'dark'
], {
position: 'top-right'
//Create a data source and add it to the map.
datasource = new atlas.source.DataSource();
//Add a simple data layer for rendering the data.
layer = new atlas.layer.SimpleDataLayer(datasource);
//Load an initial data set.
defaultOptions = layer.getOptions();
//Update the layer with the options in the input fields.
new ClipboardJS('.copyBtn');
function loadDataSet(url) {
//Read the spatial data and add it to the map. => {
if (r) {
//Update the features in the data source.
//If bounding box information is known for data, set the map view to it.
if (r.bbox) {
map.setCamera({ bounds: r.bbox, padding: 50 });
function updateLayer() {
var options = getInputOptions();
//Update all the options in the layer.
document.getElementById('CodeOutput').value = JSON.stringify(options, null, '\t').replace(/\"([^(\")"]+)\":/g, "$1:");
function getInputOptions() {
removeDefaults = document.getElementById('RemoveDefaults').checked;
return {
allowExtrusions: getPropertyValue('allowExtrusions', document.getElementById('allowExtrusions').checked),
enablePopups: getPropertyValue('enablePopups', document.getElementById('enablePopups').checked),
showPointTitles: getPropertyValue('showPointTitles', document.getElementById('showPointTitles').checked),
visible: getPropertyValue('visible', document.getElementById('visible').checked)
function getPropertyValue(propertyName, value) {
if (removeDefaults && defaultOptions[propertyName] === value) {
return undefined;
return value;
function openTab(elm, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
document.getElementById(tabName).style.display = "block";
elm.className += " active";
#myMap {
position: relative;
width: calc(100% - 375px);
min-width: 290px;
height: 600px;
float: left;
.sidePanel {
width: 325px;
height: 580px;
float: left;
margin-right: 10px;
#CodeOutput {
width: 290px;
height: 300px;
overflow-y: auto;
.copyBtn {
float: right;
table td:nth-of-type(1) {
width: 130px;
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 6px 8px;
transition: 0.3s;
font-size: 14px;
.tab button:hover {
background-color: #ddd;
.tab {
background-color: #ccc;
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
<body onload="GetMap()">
<fieldset class="sidePanel">
<legend><h1 style="font-size:16px">Simple data layer options</h1></legend>
This sample shows how the different options of the simple data layer affect rendering.
<br /><br />
Data set:<br />
<input type="button" value="Extruded KML polygons" onclick="loadDataSet('../Common/data/KML/internet_users_2005_choropleth_3D.kml')" />
<input type="button" value="Sample GeoRSS" onclick="loadDataSet('../Common/data/GeoRSS/SampleGeoRSS.xml')" />
<br /><br />
<div class="tab">
<button class="tablinks active" onclick="openTab(this, 'SimpleDataLayerOptions')">Layer Options</button>
<button class="tablinks" onclick="openTab(this, 'Code')">Code</button>
<div id="SimpleDataLayerOptions" class="tabcontent" style="display:block;">
<tr title="Specifies if polygons that have a height property should be rendered as extruded polygons. Default: true">
<td>Allow extrusions:</td>
<td><input id="allowExtrusions" type="checkbox" onclick="updateLayer()" checked="checked" /></td>
<tr title="Specifies if popups should appear when shapes are clicked. Default: true">
<td>Enable popups:</td>
<td><input id="enablePopups" type="checkbox" onclick="updateLayer()" checked="checked" /></td>
<tr title="If a point feature has a title or name property, this option specifies if it should be displayed on the map under the marker. Default: false">
<td>Show point titles:</td>
<td><input id="showPointTitles" type="checkbox" onclick="updateLayer()" /></td>
<tr title="Specifies if the layer is visible or not.">
<td><input id="visible" type="checkbox" onclick="updateLayer()" checked="checked" /></td>
In addition to the options in this tool, the simple data layer also has options for;
<li>popupTemplate - used to customize the layout of content in the popups.</li>
Note that the simple data layer uses style information stored in the properties of individual features to customize how each feature is rendered. The getLayer() function can be used to override this behaviour in the sub-layers.
<div id="Code" class="tabcontent">
<textarea id="CodeOutput"></textarea><br /><br />
<input id="RemoveDefaults" type="checkbox" onclick="updateLayer()" checked="checked" /> Remove defaults
<button class="copyBtn" data-clipboard-target="#CodeOutput">Copy to clipboard</button>
<div id="myMap"></div>
You can’t perform that action at this time.