|
POST
|
What I am finding out is that the identifyTask does not return results once my scale reaches a certain point. At large scales it works fine. At small scales past about 50,000 it no longer works. My spatial reference is webmercator(102100) if that helps, and the layer I am trying to identify on has a min scale set at 72225. So, it would seem that after 72225 it would no longer work but should work up until then. I am using esri.geometry.getScale to determine the scale and I assume that the scale returned is correct. Anyone have any ideas? Thanks. Here is my identify code: cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);
cadastral.identifyParams = new esri.tasks.IdentifyParameters();
cadastral.identifyParams.tolerance = 0;
cadastral.identifyParams.returnGeometry = true;
var identifyArray = [9];
cadastral.identifyParams.layerIds = identifyArray;
cadastral.identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE; //.LAYER_OPTION_ALL;
cadastral.identifyParams.geometry = evt.mapPoint;
cadastral.identifyParams.mapExtent = cadastral.map.extent;
cadastral.identifyTask.execute(cadastral.identifyParams, function (idResults) { cadastral.identify.setupIdentifyResults(idResults, evt); }, function (idResults) { cadastral.showError(idResults, evt); }); Usually map.mapExtent, map.height and map.width along with tolerance are used in identifyParameters to determine the search distance and visible layers. I would change the code a little bit and test it again. Suggested code:
cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);
cadastral.identifyParams = new esri.tasks.IdentifyParameters();
cadastral.identifyParams.tolerance = 1; // unless you identify a polygon layer, always give tolerance some positive value.
cadastral.identifyParams.returnGeometry = true;
cadastral.identifyParams.layerIds = [9];
cadastral.identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; //just make sure your layer 9 is always in your identify list
cadastral.identifyParams.geometry = evt.mapPoint;
cadastral.identifyParams.mapExtent = cadastral.map.extent;
cadastral.identifyParams.height = cadastral.map.height;
cadastral.identifyParams.width = cadastral.map.width;
......
Good luck
... View more
07-01-2011
06:08 AM
|
0
|
0
|
1608
|
|
POST
|
I can't work out why my map is not zooming to the extent of graphics in my featurelayer. See at the bottom of this code where I try and use the esri.graphicextent method. function initOperationalLayer(map) { var content = "<b>Street: </b>${Street_Name}, ${Suburb}<br/>" + "<b>Pickup Time: </b>${Departure_Time}"; var infoTemplate = new esri.InfoTemplate("Route 1 Details", content); var featureLayer = new esri.layers.FeatureLayer("http://gsportenf/ArcGIS/rest/services/Public_Access/MapServer/12",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], infoTemplate: infoTemplate }); map.addLayer(featureLayer); var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,255,0.35]), 1); var renderer = new esri.renderer.SimpleRenderer(symbol); featureLayer.setRenderer(renderer); map.infoWindow.resize(300,100); var zoomExtent= esri.graphicsExtent(featureLayer.graphics); map.setExtent(zoomExtent); // THE MAP IS NOT CHANGING !!! } To my understanding, you set up featurelayer displayer mode as MODE_ONDEMAND. Without definition expression and time definition, the feature layer only display features at current map extent. So featureLayer.graphics in your statement actually are not the whole features in your featureLayer but the features in your current extent. So zoomExtent =YOUR CURRENT EXTENT !!. No wonder your map is not changing.
... View more
07-01-2011
05:29 AM
|
0
|
0
|
1024
|
|
POST
|
Sorry for the slight delay in replying. That's really useful. Having seen what you have said about being able to use custom icons with the QueryTask, I thought I'd see if I could get it working - using the code that worked from the esri.request code. I get markers on the map, but they appear at 0,0 lat/long which is odd, and I'm not entirely sure why - I assume it's something to do with the wkid, but the code I'm using below seems correct - but obviously isn't! If I output the x/y/wikd I get: x - 456309, y - 520207 wkid - 3857 and these come from the layer. My base map is Bing, but I don't see how that would be a problem. Is there something obvious that I'm doing wrong which is making them appear at 0,0? Thanks.
for (var i=0, il=resultFeatures.length; i<il; i++) {
var point_x = resultFeatures.attributes.x;
var point_y = resultFeatures.attributes.y;
var point_wkid = resultFeatures.geometry.spatialReference.wkid;
//console.log(point_x +" "+ point_y +" "+ point_wkid);
var pointGraphic = new esri.Graphic(new esri.geometry.Point(point_x, point_y, new esri.SpatialReference({ wkid: point_wkid }) ), hmg.markers[4]);
pointGraphic.setInfoTemplate(infoTemplate);
map.graphics.add(pointGraphic);
}
When using eari.request, there are some of the interesting findings I thought might helpful to peers. var requestHandle = esri.request({
url: url.path, //url is a variable for the whole querystring +&f=json
content: url.query,
//handleAs: "text",
load: requestSucceeded,
error: requestFailed
}, {useProxy:true}); 1. for the same query string with &f=json, if i commented out handleAs:"text", i will get an similar error message. 2. if i commented out {useProxy:true}, i will get an similar error message. Conculsion: Proxy help to serialize your querysting text for REST quest.
... View more
06-29-2011
10:28 AM
|
0
|
0
|
1146
|
|
POST
|
I require a bit of help with some code, I'm using the following to insert an iframe into a popup. However i cant seem to get it to pull through a web page. else if (result.layerName === 'PLANNING_APP'){ var template = new esri.InfoTemplate("", "<b>Planning Application</b></br> <iframe src='http://www.rbwm.gov.uk/pam/view.jsp?ID=${REFVAL} width='100%' height='300'></iframe>'"); feature.setInfoTemplate(template); } any ideas? ></iframe>'");
... View more
06-29-2011
07:03 AM
|
0
|
0
|
592
|
|
POST
|
Hi, I develop a large number of webmapping application every year for the same costumer and in the various project at least an half of the layers are repeated. For this reason I'm evaluating the possibility to create a basic, fixed MXD containing these redundant layers and generate from it a basic Mapservice (with the 4/5 common layers). My question, at this point, is what happens when I use layers coming from two (or more) different mapservices in the same javascript api application? For example, in the following situation: Mapservice_1 (layer 0, layer 1, layer 2) Mapservice_2 (layer 0, layer 1, layer 2, layer 3) the order (in the z-axis) of the layers for every single mapservice is defined by the array index (that depends from the layer order in the mxd project) and it's ok. How can I specify in the application that Mapservice_1 layer's have to be drawn before Mapservice_2 layer's? Thanks map.addLayers([Mapservice_1, Mapservice_2])
... View more
06-29-2011
04:50 AM
|
0
|
0
|
608
|
|
POST
|
I am trying to get my website to add up the population for the cities the user select. I took the http://help.arcgis.com/en/webapi/javascript/arcgis/demos/graphics/graphics_extent_query.html as my base code and added some code from http://help.arcgis.com/en/webapi/javascript/arcgis/demos/query/query_buffer.html I think the problem is the "onComplete" it should be onDrawend, but I do not know how to do that. <!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>Points in Extent</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.3"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.toolbars.draw");
dojo.require("esri.tasks.query");
//global variables
var map, defaultSymbol, highlightSymbol, resultTemplate;
function init() {
//create map, set initial extent and disable default info window behavior
map = new esri.Map("map", {
extent: esri.geometry.geographicToWebMercator(new esri.geometry.Extent(-125.90, 44.60, -114.65, 50.22, new esri.SpatialReference({wkid:4326}))),
showInfoWindowOnClick:false
});
dojo.connect(map, "onLoad", initToolbar);
map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
//initialize symbology
defaultSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0,0,255]));
highlightSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([255,0,0]));
//initialize & execute query
var queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0");
var query = new esri.tasks.Query();
query.where = "STATE_NAME = 'Washington'";
query.outSpatialReference = {wkid:102100};
query.returnGeometry = true;
query.outFields = ["*"];
queryTask.execute(query, addPointsToMap);
//info template for points returned
resultTemplate = new esri.InfoTemplate("City", "<tr><td>${CITY_NAME}</tr></td>");
dojo.connect(queryTask, "onComplete", function(results) {
var totalPopulation = sumPopulation(results);
var r = "";
r = "<b>The Total Population of Selected Cities is <i>" + totalPopulation + "</i>.</b>";
dojo.byId('inextent').innerHTML = r;
});
}
//initialize drawing toolbar
function initToolbar(map) {
var tb = new esri.toolbars.Draw(map);
//find points in Extent when user completes drawing extent
dojo.connect(tb, "onDrawEnd", findPointsInExtent);
//set drawing mode to extent
tb.activate(esri.toolbars.Draw.EXTENT);
}
//add points to map and set their symbology + info template
function addPointsToMap(featureSet) {
dojo.forEach(featureSet.features,function(feature){
map.graphics.add(feature.setSymbol(defaultSymbol).setInfoTemplate(resultTemplate));
});
}
//find all points within argument extent
function findPointsInExtent(extent) {
var results = [];
dojo.forEach(map.graphics.graphics,function(graphic){
if (extent.contains(graphic.geometry)) {
graphic.setSymbol(highlightSymbol);
results.push(graphic.getContent());
}
//else if point was previously highlighted, reset its symbology
else if (graphic.symbol == highlightSymbol) {
graphic.setSymbol(defaultSymbol);
}
});
//display list of points in extent
dojo.byId("results").innerHTML = "<table><tbody>" + results.join("") + "</tbody></table>";
}
function sumPopulation(results) {
var features = results.features;
var popTotal = 0;
for (var x = 0; x < features.length; x++) {
popTotal = popTotal + features .attributes['POP1990'];
}
return popTotal;
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
Draw an Extent on the map to find all points within this extent
<!-- map div -->
<div id="map" style="width:800px; height:400px; border:1px solid #000;"></div>
<br />
<!-- display number of points in drawn extent -->
<b><span id="inextent">0</span></b>
<!-- list points in extent -->
<div id="results" style="width:400px; height:200px; border:1px solid #000; overflow:auto;">
</div>
</body>
</html>
There are two issues in your code. 1. You defined querytask call back twice. 2. after draw an extend, you should do another query to get the population or get the total population in your findPointsInExtent(). attached is one version of modified code.
... View more
06-28-2011
09:44 AM
|
0
|
0
|
524
|
|
POST
|
The samples page is curiously missing a decent Table of Contents example. There's the Toggle Layer Visibility sample but that's about it. Does can anyone point me to a decent Table of Contents sample for the JavaScript API? I need the ability to: support feature layers, cached layers and dynamic layers zoom to extent toggle on/off show the symbology support transparency The example here is promising but not quite right, and doesn't seem to support feature layers. The TOC in the maps you can create at ArcGIS.com is perfect - can we easily get to this functionality? Thanks, Steve Just a coment. I think it will be nice for ESRI to develop a TOC widget. It's useful, practical and saving us (developers) lots time.
... View more
06-28-2011
07:22 AM
|
0
|
0
|
729
|
|
POST
|
I have already developed a gis template with many functions with the google maps extender. Now it's too complicated to switch on the other apis only for the baselayers 🙂 I don't think you can use basemap gallery on Google Map API. But you can use ESRI base map as ArcGIS Server cached map and add it on the google maps. There are plenty sample on: http://help.arcgis.com/en/webapi/javascript/gmaps/help/google_start.htm
... View more
06-28-2011
07:14 AM
|
0
|
0
|
1121
|
|
POST
|
Hi I have set scale ranges on my dynamic service and the legend is behaving as expected (legend removes symbology for data not available at that scale range) Is there anyway to make it just display the symbology all the time and not turn on/off depending on scale? I have followed this sample http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm thanks Try this: var legend = new esri.dijit.Legend({
map:map,
respectCurrentMapScale: false
},"legendDiv");
... View more
06-28-2011
07:02 AM
|
1
|
2
|
1641
|
|
POST
|
Thanks for replying! As for the second question, I did that, but it doesn't show up when you click search. I've added another variable called marker symbol (because I'm now searching off of a point FC), but to no avail. It might have something to do with the new layer not being connected to the DataGrid, but I'm not sure. Kevin Don't specify FindParameters searchFields and run your code to see if you get any find results back from the second layer.
... View more
06-28-2011
06:59 AM
|
0
|
0
|
1023
|
|
POST
|
hi, i need to display a popup window, onmouse right click event. am new to arcgis Javascript api, i need to display layer information on the popup window on mouse right click event. I think this ESRI sample will help you: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/graphics_contextmenu.html
... View more
06-28-2011
06:27 AM
|
0
|
0
|
464
|
|
POST
|
I have, but it results in some funny behavior, which I'm sure has to do with the spatial reference... I am just unsure how to manipulate the extent from web mercator to UTM. function init() {
/* Set Extent and Create Map Constructor */
var extent = new esri.geometry.Extent({
"xmin": -75.35,
"ymin": 41.6,
"xmax": -74.06,
"ymax": 42.75,
"spatialReference": {
"wkid": 4269
}
});
map = new esri.Map("map", {
extent: esri.geometry.geographicToWebMercator(extent)
});
/* Add Basemap */
var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
var basemapInitial = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
map.addLayer(basemapInitial);
/* AA - Create Basemap Gallery */
createBasemapGallery();
...
/* AA */
function createBasemapGallery(){
/* ESRI World Street Map */
var layerStreet = new esri.dijit.BasemapLayer({
url:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
});
var basemapStreet = new esri.dijit.Basemap({
layers: [layerStreet],
title: "ESRI Street Map"
});
basemaps.push(basemapStreet);
/* New Basemap */
var newBaselayer = new esri.dijit.BasemapLayer({
url:"http://host/ArcGIS/rest/services/myservice/MapServer",
visibleLayers:[2]
});
var newBasemap = new esri.dijit.Basemap({
layers: [newBaselayer],
title: "Other Basemap"
});
basemaps.push(newBasemap);
/* Create Gallery and Populate Drop Down Menu */
basemapGallery = new esri.dijit.BasemapGallery({
showArcGISBasemaps: false,
basemaps: basemaps,
map: map
});
dojo.forEach(basemapGallery.basemaps, function(basemap){
dijit.byId("basemapMenu").addChild(new dijit.MenuItem({
label: basemap.title,
onClick: dojo.hitch(this, function(){
this.basemapGallery.select(basemap.id);
})
}));
}); So at first things are fine, and then when I switch base maps, the new (which is on a different map service and has a different spatial projection (UTM)) basemap zooms to the full extent, actually somewhat further out than that. If I then switch back to the ESRI world street map, it zooms me to a place in the Mediterranean Sea. Could anyone explain this behavior? Will I need to convert the units everytime my basemap changes? Thanks, DR To my understanding, geographicToWebMercator does not support wkid 4269. Try this: /* Set Extent and Create Map Constructor */
var extent = new esri.geometry.Extent({
"xmin": -75.35,
"ymin": 41.6,
"xmax": -74.06,
"ymax": 42.75,
"spatialReference": {
wkid:4326 }
});
map = new esri.Map("map", {
extent: esri.geometry.geographicToWebMercator(extent)
});
... View more
06-28-2011
06:16 AM
|
0
|
0
|
936
|
|
POST
|
Greetings, I'm constructing a basemap gallery drop down menu button. I've left the default World Street Map as the initial basemap, and predefined an extent. This works when loaded. When I switch basemaps through the menu (using a different Map Service), I lose the defined extent, with the new basemap having its full extent. Anybody know how to fix this so I maintain the defined extent despite map service/basemap changes? Thanks, DR Set the map extent in your map constructor, the map will honor that extent no matter how you switch your basemaps amony may gallery.
... View more
06-27-2011
09:59 AM
|
0
|
0
|
936
|
|
POST
|
Hello, I have a javascript web app, and it works fine. Being a newbie, I have a few questions as to how to expand some of the functionality. First, how would one go about flashing one of the found polygons in a datagrid, similar to the functionality you have when performing a find in ArcGIS. Secondly, I have another point layer that I'd like to perform finds on, how do I go about adding that second layer to find find function. I'll post my app for a little more clarity. Thanks in advance Kevin L. For your first question. This is how i did (code snippet); //editedId is the OBJECTID of selected feature on the map for (var i = 0; i < grid.rowCount; i++) { item = grid.getItem(i); //item = grid._by_idx.item; if (editedId == item.OBJECTID) { grid.selection.clear(); grid.selection.setSelected(i, true) //grid.focus.setFocusIndex(i, 0); //grid.selectedIndex = i; editedId = 0; } For you seconde question. If your second layer is in the same map service of your first layer, you could include it by findParams.layerIds = [firstLayerID, SecondLayerID]; if If your second layer is not in the same map service of your first layer, you most likely have to do find tasks seperately. } }
... View more
06-27-2011
05:29 AM
|
0
|
0
|
1023
|
|
POST
|
Has anyone implemented a listener to close the infoWindow when the ESC key is pressed? If so are you able to share the code, so I don't reinvent the wheel? Thanks, Steve Though i have not done this, it should be straightforward. Something like this. dojo.connect (map, "onKeyDown", function (key){ if (key.keyCode == 27) { map.infoWindow.hide(); } }); //ESC keyCode =27. keyCode =0 means no key press
... View more
06-27-2011
05:10 AM
|
0
|
0
|
1580
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-11-2011 12:16 PM | |
| 1 | 05-25-2017 08:26 AM | |
| 1 | 06-02-2017 07:37 AM | |
| 1 | 06-28-2011 07:02 AM | |
| 1 | 06-12-2017 10:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-01-2024
09:57 PM
|