|
POST
|
I should not be encouraging you to do this. You really need to use AMD however map.on is still AMD dojo.connect(map, "onLoad", function(layer) { //function }); etc.. Actually, since he is using v3.5 of the API, which introduced the AMD style to some classes, that shouldn't be a problem. What you can do is download the older versions of the SDK here. The zip file contains all the old versions of the samples, such as this for showing the XY coordinate in legacy style. <!DOCTYPE html> <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"> <!--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>Create Map Display Mouse Coordinates</title> <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css"> <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"></script> <script> dojo.require("esri.map"); var map; function init() { map = new esri.Map("map", { basemap: "streets", center: [-47.109, 14.945], zoom: 2 }); map.on("load", function(){ //after map loads, connect to listen to mouse move & drag events map.on("mouse-move", showCoordinates); map.on("mouse-drag", showCoordinates); }); } function showCoordinates(evt) { console.log("show"); //get mapPoint from event //The map is in web mercator - modify the map point to display the results in geographic var mp = esri.geometry.webMercatorToGeographic(evt.mapPoint); //display mouse coordinates dojo.byId("info").innerHTML = mp.x.toFixed(3) + ", " + mp.y.toFixed(3); } dojo.ready(init); </script> </head> <body class="claro"> <div id="map" style="position:relative; width:900px; height:600px; border:1px solid #000;"> <span id="info" style="position:absolute; left:15px; bottom:5px; color:#000; z-index:50;"></span> </div> </body> </html>
... View more
05-22-2014
12:25 PM
|
0
|
0
|
1526
|
|
POST
|
You can define any sort of function you'd like, but until you call it, it won't do anything. You'd essentially have to do something like this case "extractByUnit": executeQueryTask1(unit); function executeQueryTask1(unit) { var clipLayers = []; if (registry.byId("layer1").get("checked")) { clipLayers.push("SRA"); } etc. Here's an example showing the difference. Try clicking all three buttons to see what happens. As for your "addTomap" error, you probably have the function name misspelled. But you say "addtomap" is a function that i call outside the switch function. Remember that JavaScript is case sensitive.
... View more
05-21-2014
12:21 PM
|
0
|
0
|
2048
|
|
POST
|
The way you have it written, you're defining functions within each case, but never calling them. And be aware that the way it's currently written where you keep defining the variable extractMethod, it will only run the "extractByUnit" method. This value should be set outside the function. Try something like this
set the extractMethod somewhere outside this function
function myFunction() {
//var extractMethod = "extractByPoly";
//var extractMethod = "extractByCounty";
//var extractMethod = "extractByUnit";
switch (extractMethod) {
default:
//function extractData() {
//get clip layers
var clipLayers = [];
if (registry.byId("layer1").get("checked")) {
clipLayers.push("SRA");
}
if (registry.byId("layer2").get("checked")) {
clipLayers.push("Burn");
}
if (clipLayers.length === 0 || map.graphics.graphics.length === 0) {
alert("Select layers to extract and draw an area of interest.");
return;
}
var featureSet = new FeatureSet();
var features = [];
features.push(map.graphics.graphics[0]);
featureSet.features = features;
var params3 = {
"Layers_to_Clip": clipLayers,
"Area_of_Interest": featureSet,
"Feature_Format": registry.byId("formatBox").get("value")
};
domStyle.set(loading2, "display", "inline-block");
gp.submitJob(params3, completeCallback, statusCallback2, function (error) {
alert(error);
domStyle.set(loading2, "display", "none");
});
//}
break;
case "extractByCounty":
//function executeQueryTask(county) {
var clipLayers = [];
if (registry.byId("layer1").get("checked")) {
clipLayers.push("SRA");
}
if (registry.byId("layer2").get("checked")) {
clipLayers.push("Burn");
}
if (clipLayers.length === 0) {
alert("No layers to clip, please select a layer you would like to clip...");
return;
}
var county = document.getElementById("sel_county").value
var unit = document.getElementById("sel_unit").value
var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Counties/MapServer/0");
var queryTask1 = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Layers/MapServer/1");
queryTask.on("complete", addToMap)
var query = new Query();
query.returnGeometry = true;
query.outFields = ["NAME_PCASE"];
query.where = "NAME_PCASE = '" + county + "'";
query.outSpatialReference = map.spatialReference;
queryTask.execute(query, function (featureSet) {
var AOI = featureSet.features[0].geometry;
var graphic = new Graphic(AOI, symbol);
var features = [];
features.push(graphic);
var fSet = new FeatureSet();
fSet.features = features;
var params = {
"Layers_to_Clip": clipLayers,
"Area_of_Interest": fSet,
"Feature_Format": registry.byId("formatBox").get("value")
};
domStyle.set(loading, "display", "inline-block");
gp.submitJob(params, completeCallback, statusCallback, function (error) {
alert(error);
domStyle.set(loading, "display", "none");
});
});
//}
break;
case "extractByUnit":
//function executeQueryTask1(unit) {
var clipLayers = [];
if (registry.byId("layer1").get("checked")) {
clipLayers.push("SRA");
}
if (registry.byId("layer2").get("checked")) {
clipLayers.push("Burn");
}
if (clipLayers.length === 0) {
alert("No layers to clip, please select a layer you would like to clip...");
return;
}
var unit = document.getElementById("sel_unit").value
var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Layers/MapServer/1");
queryTask.on("complete", addToMap2)
var query = new Query();
query.returnGeometry = true;
query.outFields = ["UNITCODE"];
query.where = "UNITCODE = '" + unit + "'";
query.outSpatialReference = map.spatialReference;
queryTask.execute(query, function (featureSet) {
var AOI = featureSet.features[0].geometry;
var graphic = new Graphic(AOI, symbol);
var features = [];
features.push(graphic);
var fSet = new FeatureSet();
fSet.features = features;
var params2 = {
"Layers_to_Clip": clipLayers,
"Area_of_Interest": fSet,
"Feature_Format": registry.byId("formatBox").get("value")
};
domStyle.set(loading1, "display", "inline-block");
gp.submitJob(params2, completeCallback, statusCallback1, function (error) {
alert(error);
domStyle.set(loading1, "display", "none");
});
});
//}
}
}
... View more
05-21-2014
11:11 AM
|
0
|
0
|
2048
|
|
POST
|
If your code is in AMD, then this is a problem of scoping. The "myFunction" function is not available in the HTML portion of your code. Instead, you should create a listener for the button in your script. See the documention for dojo events. You'd use something like this
HTML
<button id="myButton" data-dojo-type="dijit/form/Button" data-dojo-props="iconClass:'DownIcon', showLabel:false">
JavaScript
require(["dijit/registry"], function(registry){
registry.byId("myButton").on("click", myFunction);
});
... View more
05-21-2014
10:09 AM
|
0
|
0
|
2048
|
|
POST
|
You can specify the number of LODs that your map has. Take a look at this sample.
... View more
05-21-2014
06:45 AM
|
0
|
0
|
3668
|
|
POST
|
The number of LODs don't have to match, but the resolution and scale have to match. For example, I have created a tiled service that doesn't have all the LODs of the Ocean basemap, but if you look at the scale and resolution of the different levels, you'll see that they match (Level 0 in my service and Level 12 on the Ocean service have a scale of 144447.638572 and a resolution of 38.2185141425366). You can limit the number of LODs that the user can zoom to on your map, as shown in this sample.
... View more
05-20-2014
09:20 AM
|
0
|
0
|
1156
|
|
POST
|
David, Take a look at this example that shows how to add checkboxes for layers in multiple services. By combining this logic with the posts the John has included, you should be able to get things working.
... View more
05-16-2014
02:17 PM
|
0
|
0
|
1089
|
|
POST
|
Does the Tiled Service have the same Levels of Detail (LODs) as the standard basemaps? If not, then you won't be able to display both at the same time. Compare the LODs of your service with one of the basemaps (like this).
... View more
05-16-2014
01:58 PM
|
0
|
0
|
1156
|
|
POST
|
Could you put this into something like JSBin to show what exactly is happening?
... View more
05-15-2014
09:18 AM
|
0
|
0
|
1194
|
|
POST
|
Glad to help. Don't forget to click the checkbox in the post to signify your question was answered. This will help others as they search for solutions for similar questions. See this page for more information.
... View more
05-15-2014
09:12 AM
|
0
|
0
|
1410
|
|
POST
|
A good place to start is this blog, which should help you get up to speed on using AMD. I'm guessing what's going on is you have the HomeButton module out of place in the require statement. While you can leave off the arguments in the function section, any arguments will have to be in the same order as when they are called in the require part. For example require([
"esri/map", "esri/layers/FeatureLayer",
"dojo/parser", "dijit/layout/BorderContainer", "dojo/domReady!"
], function (
Map, FeatureLayer,
parser
) { I don't have an argument for "BoarderContainer, but it has to come after any modules that have an argument in the function section.
... View more
05-15-2014
05:36 AM
|
0
|
0
|
1410
|
|
POST
|
Brandon, You should mark Tim's post as the answer by clicking the checkbox on his post. This will help others when searching for answers on this topic. Take a look at this page for more information.
... View more
05-15-2014
05:19 AM
|
0
|
0
|
2913
|
|
POST
|
I did notice a difference between the two apps you listed. If I resize the desktop browser to a much smaller size, the Shortlist will be responsive and change appearance to fit the smaller screen size. However, the Playlist does not do that. If I look at the Playlist on my smartphone, it does show the different layout. [ATTACH=CONFIG]33835[/ATTACH][ATTACH=CONFIG]33836[/ATTACH]
... View more
05-15-2014
05:01 AM
|
0
|
0
|
2308
|
|
POST
|
The code is having a problem with the node "HomeButton" (in red) that is never defined in your markup var homebutton = new HomeButton({
map: map
}, "HomeButton");
</script>
</head>
<body>
<div id="search"></div>
<div id="map"></div>
</body>
</html> If you look at the HomeButton sample, you'll see that its markup contains a div named "HomeButton" where yours doesn't.
<body>
<div id="map" class="map">
<div id="HomeButton"></div>
</div>
</body>
</html>
... View more
05-15-2014
04:15 AM
|
0
|
0
|
2913
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 2 weeks ago | |
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|