|
POST
|
You need to look through the threads searching for queryTasks and deferred. When you execute multiple queries, you have to wait for all queries to finish before you proceed. ( In AMD-style you're searching for promise/all instead.) It can be rather complicated to wrap your head around, but its the way you have to set it up.
... View more
04-25-2014
07:02 AM
|
0
|
0
|
1208
|
|
POST
|
I'm not using strictly featureLayers, but the logic should still be the same. Since I am using a TOC, the user has control of the visibility and the identifyTask and identifyParameters have to be responsive to that. Depending on what is currently turned on, the identify will show a popup window with the contents. It managed multiple services and a variety of different outFields. I'm managing those by defining an array for each layer at the top and then generating the infoContent on the fly. Assuming you're using something like Firebug in Firefox you should be able to see my code. https://ogi.oa.mo.gov/LEGIS/LegislativeDistrict/index.html
... View more
04-18-2014
05:31 AM
|
0
|
0
|
920
|
|
POST
|
A lot of the events for the map don't have any input parameters, but it looks like layer-add-result does. In the documentation, it says that the layer-add-result fires when you add the specified layer. But what is the syntax for this? I want to be able to see specifically when a particular layer is added, not just the plural version, layers-add-result.
... View more
04-17-2014
08:13 AM
|
0
|
3
|
5869
|
|
POST
|
There are several threads that discuss various resize issues with the map objects. One of the recommendations is to have the autoResize parameter on the map constructor set to false. Then you have add a listener to manually execute map.resize and map.reposition. To me that's a very clunky solution and it would be better if there was something changed with the map object to handle this better. It helped me to have a listener on the transition between views. The functions for the mapHeight are something I got from an ESRI blog on designing for mobile, which included a sample to download. I still don't have all the kinks worked out. I think I have it working and then suddenly it will look all cropped again. If you perfect this, let me know and I'll fix my code too.
var map = new Map("mapDiv", {
basemap: "streets",
center: [-92.593, 38.5],
zoom: 6,
autoResize:false
});
map.on("load", mapLoadHandler);
function mapLoadHandler(evt){
registry.byId('mapView').on('AfterTransitionIn', resizeMap);
}
function resizeMap() {
mobile.hideAddressBar();
adjustMapHeight();
map.resize();
map.reposition();
}
function adjustMapHeight() {
var headHeight = registry.byId('mapHeader').domNode.clientHeight;
var availHeight = mobile.getScreenSize().h - headHeight - 60;
if (has('iphone') || has('ipod')) {
availHeight += iphoneAdjustment();
}
dom.byId("mapDiv").style.height = availHeight + "px";
dom.byId("mapDiv").style.width = "100%";
}
function iphoneAdjustment() {
var sz = mobile.getScreenSize();
if (sz.h > sz.w) { //portrait
//Need to add address bar height back to map because it has not been hidden yet 44 = height of bottom safari button bar
return screen.availHeight - window.innerHeight - 44;
} else { //landscape
//Need to react to full screen / bottom button bar visible toggles
var _conn = on(window, 'resize', function() {
_conn.remove();
resizeMap();
});
return 0;
}
}
... View more
04-16-2014
06:14 AM
|
0
|
0
|
1318
|
|
POST
|
I do. These are some pretty old map services made a few years ago that I thought were in WGS 1984 Aux Sphere (102100). When I studied them more closely, I realized they were in just WGS 1984, which is something like wkid 4326. I ended up going back and fixing my original MXD files and getting them into the projection I really meant for them to be in (102100). All that and it still wasn't working!!! I know it should have worked, but my end around was to create an array of adjacent county names from the original county service. Then I generated a rather elaborate where clause from that array and used that as input to my 2nd layer (both had county name fields) and got at the information that way.
function findAdjacentCounties(geometry) {
var queryTask = new QueryTask(countyLayer.url+"/0");
var query = new Query();
query.geometry = geometry;
query.spatialRelationship = Query.SPATIAL_REL_TOUCHES;
query.outFields=["*"];
queryTask.on('error', taskErrorHandler);
queryTask.execute(query, findAdjResultHandler);
}
function findAdjResultHandler(results) {
countyList.length = 0;
var fs = results.features;
countyList.push(registry.byId("countySelect").value.toUpperCase());//to get data for the current county too
arrayUtil.forEach(results.features, function(feature){
countyList.push (feature.attributes.COUNTYNAME.toUpperCase());
});
clause = createWhere(countyList);
}
function createWhere(inputArray){//creates a query where clause based on the adjacent county names
var s = "";
arrayUtil.forEach(inputArray, function(item, i){
if (i < inputArray.length - 1){
s = s + '"NAME2" = ' + "'" + inputArray + "'" + ' OR ';
}else {
s = s + '"NAME2" = ' + "'" + inputArray + "'";
}
});
// console.log("where clause is " + s);
return s;
}
function queryAdjacentCounties(){
var currentVis = ncdmLayer.visibleLayers;
var queryTask = new QueryTask(ncdmLayer.url+"/" +currentVis);
var query = new Query();
query.outFields=["NAME", "NAME2", "RATE"];
query.where = clause;
query.returnGeometry = false;
queryTask.on('error', taskErrorHandler);
queryTask.on('complete', queryAdjResultHandler);
queryTask.execute(query);
}
... View more
04-16-2014
05:48 AM
|
0
|
0
|
987
|
|
POST
|
I think it would be helpful for you to read through this thread: http://forums.arcgis.com/threads/105742-Combine-two-Examples-with-Buttons-to-activate-code?highlight=connect.disconnect+click You will probably end up need to set some sort of Boolean variable that you alternate between true/false to determine the status of whether you just clicked the buffer button or not. You'll also have to manage your map click events. This is discussed on this other thread.
... View more
04-14-2014
06:11 AM
|
0
|
0
|
3608
|
|
POST
|
What are you trying to turn on/off, the buffer graphic? Every map has one graphicLayer by default, but you can create and populate as many as you want. https://developers.arcgis.com/javascript/jsapi/graphicslayer-amd.html I think if you put the buffer graphic into a graphic layer you create, you'll have more control over the visibility. Once your graphics are in a layer, rather than part of the map, you should be able to control them as layers, not graphics. I use a this simple function that takes a layer name as an argument whenever I want to do something like this. Then I put a click event on a button that passes the layer name to it.
function toggleLayer (layerId) {
var layer = map.getLayer(layerId);
if (layer.visible){
layer.setVisibility(false);
}else{
layer.setVisibility(true);
}
}
... View more
04-14-2014
05:27 AM
|
0
|
0
|
3608
|
|
POST
|
I have a basic county boundary service that I'm using as input to a FindTask, based on a county name pick list. Later, the user should have the option to use the geometry of that found polygon as the input geometry of a querytask which searches on other county polygon layers. My basic county service is in UTM, but my project is wkid 102100 and so is the layer I'm trying to search in the queryTask. I have the output spatialReference of my findParameters set to that same wkid, which I assume should make the geometry from the find be in the right coordinates. If the use clicks the "find neighbors" button, it executes the findAdjacentCounties function, which runs a query/QueryTask using Query.SPATIAL_REL_TOUCHES. The query executes without error, but it never returns any features, I assume because the inputGeometry I'm providing doesn't actually touch any of other features. The coordinates of the countyGeometry variable says it's wkid 102100.
//This functions searches the countyLayer, defined earlier to zoom to a county and saves the geometry
function zoomCounty () {
var findTask = new FindTask(countyLayer.url); //layer defined earlier
var findParams = new FindParameters();
findParams.returnGeometry = true;
findParams.layerIds = [0];
findParams.searchFields = ["COUNTYNAME"];
findParams.outSpatialReference = spatialReference;
var countyName = registry.byId("countySelect").value;
findParams.searchText = countyName;
findTask.execute(findParams, function (results) {
map.setExtent(results[0].feature.geometry.getExtent());
currentExtent = map.extent;
currentCenter = results[0].feature.geometry.getCentroid();
countyGeometry = results[0].feature.geometry; // polygon geometry getting stored
});
}
//this executes when the user selects the 'find neighbor' button
function findAdjacentCounty() {
var currentVis = ncdmLayer.visibleLayers;//layer defined earlier
var queryTask = new QueryTask(ncdmLayer.url+"/" +currentVis);
var query = new Query();
query.geometry = countyGeometry;
query.outSpatialReference = spatialReference;
query.spatialRelationship = Query.SPATIAL_REL_TOUCHES;
query.outFields=["NAME", "NAME2", "RATE"];
// query.returnGeometry = true;
queryTask.on('error', taskErrorHandler);
queryTask.execute(query, adjacentResultHandler);
}
//this function executes, but results is always empty!
function adjacentResultHandler(results) {
countyList.length = 0; //arrays defined earlier
countyRateList.length = 0;
arrayUtil.forEach(results.features, function(feature){
countyList.push(feature.attributes.NAME);
countyRateList.push(feature.attributes.RATE);
});
console.log(countyList);
console.log(countyRateList);
}
I made a basic sample before I started, but it was using all the same layer, both for the find and query tasks. Now I need to use two different ones.
... View more
04-11-2014
12:31 PM
|
0
|
2
|
1588
|
|
POST
|
I'm attempting to use just the compact build and use all dojox/mobile type components. I needed a dropdown list of county names and I wanted to have something that was fairly small that didn't take up the whole screen. On other projects, I wasn't using the compact build and everything styled fine. When I tried to use a dijit/form/FilteringSelect in this paired down version, instead of having a nice dropdown arrow next to my choices, I ended up with some strange styling. [ATTACH=CONFIG]32920[/ATTACH] Instead of trying to switch to the full version of the API, I switched to using a dojox/mobile/combobox. This has the option to allow the user to enter something into the input field as well as pick from the dropdown. The problem with this is that sometimes to keyboard that pops up on a phone will dismiss cleanly, showing your results, but other time it continues to leave a blank spot on the screen where the keyboard used to be.
<select data-dojo-type="dijit/form/DataList" data-dojo-props="id:'countyList'">
<option selected>Adair</option>
<option>Andrew</option>
<option>Atchison</option>
<option>Audrain</option>
<option>Barry</option>
<option>Barton</option>
<option>Bates</option>
<option>Benton</option>
<option>Bollinger</option>
<option>Boone</option>
<option>Buchanan</option>
<option>Butler</option>
<option>Caldwell</option>
<option>Callaway</option>
</select>
<input id="countySelect" type="text" data-dojo-type="dojox/mobile/ComboBox" data-dojo-props="list:'countyList'" placeHolder="Select a county" />
Should I have just stuck with my FilteringSelect and loaded the full version of the API? Is there something I could have done to have just loaded what I needed for FilteringSelect? Doing a require for "dijit/form/FilteringSelect" obviously wasn't enough, because the style was completely wonky. http://gis.dhss.mo.gov/Website/VFC/index.html
... View more
04-08-2014
07:49 AM
|
0
|
2
|
1713
|
|
POST
|
It works in this stripped down example, but when I combine it with the full project, it still isn't working. I know I must be close, but I haven't figured out where my issues are yet. Since my map is only a set of county boundaries, I might discover the user doesn't want that anyway, they'd just as soon work just from a dropdown of names and call it good.
... View more
04-04-2014
10:57 AM
|
0
|
0
|
946
|
|
POST
|
A couple of things come to mind: It could be that some of your polygons have more vertices and you need to have a proxy page set up to handle the number of features. There's lots of threads that discuss when and why you need a proxy configured. Another thing could be that the sometimes when you've made a request that's going to return a lot of information, the result function is trying to run before the task is completely done executing. You can try changing your code so that it doesn't fire the results function until the query is completed.
feature.on("click", function (evt) {
map.graphics.clear();
var highlightGraphic = new Graphic(evt.graphic.geometry, highlightSymbol);
map.graphics.add(highlightGraphic);
var query = new Query();
var queryTask = new QueryTask("featurelayer");
query.geometry = evt.graphic.geometry;
query.returnGeometry = true;
query.outSpatialReference = map.spatialReference;
query.outFields = ["*"];
queryTask.on('complete', queryResultsHandler);
queryTask.execute(query);
});
});
function queryResultsHandler(results){
alert(results.features.length);
}
... View more
04-03-2014
08:43 AM
|
0
|
0
|
1041
|
|
POST
|
I have a map in a titlePane. I want to be able to minimize the titlePane to give more room on the screen. If my titlePane is open when I resize, the map is fine. If I have it closed when I resize my browser window, then the map is cropped and my featureLayer isn't even getting drawn. I've read some of the threads about how I need to set the map parameter to "autoResize:false" and then manage my map resizing manually. I think I'm doing this, but apparently I have something out of sequence. http://jsfiddle.net/schlot/qxut9/
... View more
04-03-2014
08:19 AM
|
0
|
3
|
1600
|
|
POST
|
Even though you are buffering a point, the resultant buffer is a polygon. You will have a large number of coordinates from that process, so no matter what you are buffering, you'll have to set up the proxy.
... View more
04-02-2014
01:44 PM
|
0
|
0
|
2481
|
|
POST
|
It's not random, they're laid down in the order you specify in map.addLayers. The one you want on top should be listed last, not first.
... View more
04-02-2014
01:23 PM
|
0
|
0
|
2544
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-02-2017 02:38 PM | |
| 2 | 03-18-2022 10:14 AM | |
| 2 | 02-18-2016 06:28 AM | |
| 1 | 03-18-2024 07:29 AM | |
| 4 | 08-02-2023 06:08 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-25-2025
01:56 PM
|