map.setScale($("#mapScale").val());
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>Testing</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css" /> <style> html,body { height: 100%; width: 100%; margin: 0; padding: 0; } #map { overflow: hidden; height: 100%; width: 100%; } #toolsDiv { position: absolute; left: 60px; top: 20px; z-index: 2; } </style> <script type="text/javascript">var djConfig = {parseOnLoad: true};</script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.5"></script> <script type="text/javascript"> var map; require(["dojo/ready"], function(ready) { ready(function() { require(["esri/map"], function(Map){ map = new Map("map", { basemap: "topo", center: [-98.57, 39.82], zoom: 4 }); }) }); }); function exportMap() { require(["esri/geometry/scaleUtils", "dojo/dom"], function(scaleUtils, dom) { var extent = scaleUtils.getExtentForScale(map, dom.byId("scaleBox").value); var url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/export?bboxSR=&layers=&layerdefs=&size=&imageSR=&format=png&transparent=false&dpi=&time=&layerTimeOptions=&f=image" var bbox = "&bbox=" + extent.xmin + "," + extent.ymin + "," + extent.xmax + "," + extent.ymax window.open(url + bbox); }); } </script> </head> <body class="claro" style="width:100%; height:100%"> <div id="map" style="width:100%; height:100%"> <div id="toolsDiv"> <input id="scaleBox" type="text" name="scaleBox" data-dojo-type="dijit/form/TextBox" value="Enter scale. eg. 10000" /> <button id ="goButton" type="button" name="goButton" data-dojo-type="dijit/form/Button" onclick="exportMap()">Export</button> </div> </div> </body> </html>
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.