This sample shows how to display a map from ArcGIS.com in a sample layout created using the Dojo layout widgets. This layout displays the Map at full width and height with no borders or margin space.This layout is ideal
to overlay html elements on top of the map.
The data for the sample application comes from an ArcGIS.com map. You can use ArcGIS.com to discover existing maps or create your own. After creating the map, you can use this sample layout to build an application with little or no development required.
The application has the url parameters listed below. If no url parameters are specified, the sample uses hardcoded values from within the application.
webMap=a193c5459e6e4fd99ebf09d893d65cf0
For additional information on working with the Dojo layout widgets see the Build Application Layouts help document.
Note: In the sample application the CSS and JavaScript are inlined in the page to make it easier to view the code. However in the real world the CSS and JavaScript are typically contained in external files. Click here to download a zipped version of the sample which uses external files for the JavaScript and CSS.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
Full Map Layout
</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
<style type="text/css">
html,body {
height:100%;
width:100%;
margin:0;
padding:0;
}
body {
background-color:#777;
overflow:hidden;
font-family:"Trebuchet MS";
}
#map {
overflow:hidden;
}
</style>
<script type="text/javascript">
var djConfig = {
parseOnLoad: true
};
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1">
</script>
<script type="text/javascript">
dojo.require("dijit.dijit"); // optimize: load dijit layer
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.arcgis.utils");
var map;
function init() {
var urlObject = esri.urlToObject(document.location.href);
var agoId;
var bingMapsKey;
if (urlObject.query) {
agoId = urlObject.query.webmap;
bingMapsKey = urlObject.query.bingMapsKey;
}
else {
agoId = "83e5fde80c0e4f5f89eca416e73f8c17"
}
var itemDeferred = esri.arcgis.utils.getItem(agoId);
itemDeferred.addCallback(function(itemInfo) {
var mapDeferred = esri.arcgis.utils.createMap(itemInfo, "map", {
mapOptions: {
slider: false,
nav:false
},
bingMapsKey: bingMapsKey,
geometryServiceURL: "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
});
mapDeferred.addCallback(function(response) {
map = response.map;
dojo.connect(dijit.byId('map'), 'resize', resizeMap);
});
mapDeferred.addErrback(function(error) {
console.log("Map creation failed: ", dojo.toJson(error));
});
});
itemDeferred.addErrback(function(error) {
console.log("getItem failed: ", dojo.toJson(error));
});
}
function resizeMap() {
//resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in
//the following help topic for more details http://help.esri.com/EN/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_guidelines.htm
var resizeTimer;
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
map.resize();
map.reposition();
}, 500);
}
//show map on load
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false"
style="width: 100%; height: 100%; margin: 0;">
<div id="map" dojotype="dijit.layout.ContentPane" region="center">
<div id="bingLogo" style="position: absolute;bottom: 2px;left: 3px;display:none;z-index:49;">
<img src="images/bing_logo.png" border="0" />
</div>
</div>
</div>
</body>
</html>