<!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" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title>Topographic Map</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/claro/claro.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .esriScalebar { padding: 20px 20px; } #map { padding:0; } </style> <script type="text/javascript"> var djConfig = { parseOnLoad: true }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("dijit.form.ComboBox"); var map; function init() { var initExtent = new esri.geometry.Extent({ "xmin": -122.46, "ymin": 37.73, "xmax": -122.36, "ymax": 37.77, "spatialReference": { "wkid": 4326 } }); map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(initExtent) }); //Add the topographic layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"); map.addLayer(basemap); dojo.connect(map, 'onLoad', function (theMap) { //resize the map when the browser resizes dojo.connect(dijit.byId('map'), 'resize', map, map.resize); }); } 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='lp' dojotype='dijit.layout.ContentPane' region='left' style='width:300px;'> <select id="boroughSelect" dojotype="dijit.form.ComboBox" autoComplete="true" forceValidOption="false" onchange="executeMenuQuery(this)"> <option>Manhattan</option> <option>Brooklyn</option> <option>Bronx</option> <option>Staten Island</option> <option>Queens</option> </select> </div> <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:1px solid #000;padding:0;"></div> </div> </body> </html>
So are you saying I cannot run the examples given by ESRI using Aptana or Notepad++ unless through a web server?In either case, I have been having trouble using 3.1 running from both localhost (through MVC) and running as a file from an editor. For the most part 2.1 has worked, but now I am having trouble using the locator class (as given in the ESRI example http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm).
Thanks, I found the source of the error, it was in the css.I need to change your code to version 2.1 for the map to load properly. Do I need to install an update or do something else so that I can use the 3.1 API?Thanks for your help, Jason
<!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" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title>Topographic Map</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/claro/claro.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .esriScalebar { padding: 20px 20px; } #map { padding:0; } </style> <script type="text/javascript"> var djConfig = { parseOnLoad: true }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("dijit.form.ComboBox"); dojo.require("dijit.layout.AccordionContainer"); var map; function init() { var initExtent = new esri.geometry.Extent({ "xmin": -122.46, "ymin": 37.73, "xmax": -122.36, "ymax": 37.77, "spatialReference": { "wkid": 4326 } }); map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(initExtent) }); //Add the topographic layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"); map.addLayer(basemap); dojo.connect(map, 'onLoad', function (theMap) { //resize the map when the browser resizes dojo.connect(dijit.byId('map'), 'resize', map, map.resize); }); } 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='lp' dojotype='dijit.layout.AccordionContainer' region='left' style='width:300px;'> <div dojotype='dijit.layout.ContentPane' title='pane1'> Content for Pane 1 </div> <div dojotype='dijit.layout.ContentPane' title='pane 2'> <select id="boroughSelect" dojotype="dijit.form.ComboBox" autoComplete="true" forceValidOption="false" onchange="executeMenuQuery(this)"> <option>Manhattan</option> <option>Brooklyn</option> <option>Bronx</option> <option>Staten Island</option> <option>Queens</option> </select> </div> </div> <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:1px solid #000;padding:0;"></div> </div> </body> </html>
<script type="text/javascript"> var djConfig = { parseOnLoad: true }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/Grid.css"> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/claroGrid.css"> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/image/resources/image.css">
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.