|
POST
|
Hi Heming Thanks a lot for your help with this, figured out that I need to use the geometry property just as I posted my last reply. Thanks again! 🙂 PS - How can I give you credit for this? I cannot find a "this post answered my question" option anywhere? Don't mention it. Just want to help
... View more
07-11-2011
06:49 AM
|
0
|
0
|
1900
|
|
POST
|
Hi Heming I put an alert in the onrowclick function to write the attributes of graphic just to see what I would get. Before it was just saying undefined but it now successfully shows the Ref_ID value of the row I clicked on which means the code you provided has worked. The problem now is I do not have the X,Y coordinates to use in the attributes to do a zoom to point (I do not have X,Y coordinates available in the candidate fields to use so will have to use the candidate.location values somehow).
dojo.forEach(map.graphics.graphics,function(graphic){
if((graphic.attributes) && graphic.attributes.IDENT === clickedAddressId){
selectedAddress = graphic;
return;
}
});
//map.centreAndZoom(selectedAddress,7);
map.centreAndZoom(selectedAddress.geometry,7);
}
... View more
07-11-2011
06:26 AM
|
0
|
0
|
2142
|
|
POST
|
Thanks Heming that was very helpful, I have now managed to get my candidate addresses into the data grid with my desired fields! Using the find sample I would now like to be able to zoom to each individual feature from the grid but am having some problems here. In the original find sample the variable 'graphic' is defined as the result.feature of the find task which has attributes assigned to it already. I have assigned attributes to the 'graphic' variable in my code but it does not seem to work. Is there anything obviously wrong with the below code as to why it might not zoom to each address point? //CODE function locate() { map.graphics.clear(); var searchResult = dijit.byId("addressSearch").value; var address = {"Single Line Input": searchResult}; locator.addressToLocations(address,["Ref_ID, Score, Match_addr"]); } function showResults(candidates) { var symbol = new esri.symbol.SimpleMarkerSymbol(); symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE); symbol.setColor(new dojo.Color([153,0,51,0.75])); //create array of attributes var items = dojo.map(candidates,function(candidate){ var geom = esri.geometry.Point(candidate.location); var attributes = {IDENT:candidate.attributes.Ref_ID}; var graphic = new esri.Graphic(geom, symbol, attributes); //add a graphic to the map at the geocoded location map.graphics.add(graphic); return candidate.attributes; }); var data = { identifier: "Ref_ID", //This field needs to have unique values label: "Ref_ID", //Name field for display. Not pertinent to a grid but may be used elsewhere. items: items }; //Create data store and bind to grid. store = new dojo.data.ItemFileReadStore({ data:data }); var grid = dijit.byId('grid'); grid.setStore(store); } function onRowClickHandler(evt){ var clickedAddressId = grid.getItem(evt.rowIndex).Ref_ID; var selectedAddress; dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.IDENT === clickedAddressId){ selectedAddress = graphic; return; } }); map.centreAndZoom(selectedAddress,7); } //FINISH CODE Replace the statement: var attributes = {IDENT:candidate.attributes.Ref_ID} with var attributes = candidate.attributes and tried again.
... View more
07-11-2011
05:03 AM
|
0
|
0
|
2142
|
|
POST
|
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_legendvisible.html I saw this example and wanted to see if there was a way to have the check box not checked(dynampic map not visible) when the page was loaded. For example not have the "Fire" layer visible when the page was loaded. Thanks <!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>Updating the legend to display visible layers</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/dojo/dijit/themes/claro/claro.css">
<style>
html, body { height: 98%; width: 98%; margin: 0; padding: 5px; }
#rightPane{
width:20%;
}
#legendPane{
border: solid #97DCF2 1px;
}
</style>
<script type="text/javascript">var djConfig = {parseOnLoad: true};</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.3"></script>
<script type="text/javascript">
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.AccordionContainer");
dojo.require("esri.map");
dojo.require("esri.dijit.Legend");
dojo.require("esri.arcgis.utils");
dojo.require("dijit.form.CheckBox");
var map;
var legendLayers = [];
function init() {
var initialExtent = new esri.geometry.Extent({"xmin":-13133288,"ymin":4020012,"xmax":-13016186,"ymax":4090945,"spatialReference":{"wkid":102100}});
map = new esri.Map("map", { extent: initialExtent});
//Add the terrain service 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);
var quakeLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer",{id:'quakes'});
legendLayers.push({layer:quakeLayer,title:'Earthquakes'});
var fireLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/MapServer",{id:'fire'});
legendLayers.push({layer:fireLayer,title:"Fire"});
dojo.connect(map,'onLayersAddResult',function(results){
var legend = new esri.dijit.Legend({
map:map,
layerInfos:legendLayers
},"legendDiv");
legend.startup();
});
map.addLayers([fireLayer,quakeLayer]);
dojo.connect(map,'onLayersAddResult',function(results){
//add check boxes
dojo.forEach(legendLayers,function(layer){
var layerName = layer.title;
var checkBox = new dijit.form.CheckBox({
name: "checkBox" + layer.layer.id,
value: layer.layer.id,
checked: layer.layer.visible,
onChange: function(evt) {
var clayer = map.getLayer(this.value);
if (clayer.visible) {
clayer.hide();
} else {
clayer.show();
}
this.checked = clayer.visible;
}
});
//add the check box and label to the toc
dojo.place(checkBox.domNode,dojo.byId("toggle"),"after");
var checkLabel = dojo.create('label',{'for':checkBox.name, innerHTML:layerName},checkBox.domNode,"after");
dojo.place("<br />",checkLabel,"after");
});
});
//resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in
//the following help topic for more details http://help.esri.com/EN/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_guidelines.htm
var resizeTimer;
dojo.connect(map, 'onLoad', function(theMap) {
dojo.connect(dijit.byId('map'), 'resize', function() { //resize the map if the div is resized
clearTimeout(resizeTimer);
resizeTimer = setTimeout( function() {
map.resize();
map.reposition();
}, 500);
});
});
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="content" dojotype="dijit.layout.BorderContainer" design="headline" gutters="true" style="width: 100%; height: 100%; margin: 0;">
<div id="rightPane" dojotype="dijit.layout.ContentPane" region="right">
<div dojoType="dijit.layout.AccordionContainer">
<div dojoType="dijit.layout.ContentPane" id="legendPane" title="Legend" selected="true">
<div id="legendDiv"></div>
</div>
<div dojoType="dijit.layout.ContentPane" title="Natural Disasters" >
<span style="padding:10px 0;">Click to toggle the visibilty of the various natural disasters</span>
<div id="toggle" style="padding: 2px 2px;"></div>
</div>
</div>
</div>
<div id="map" dojotype="dijit.layout.ContentPane" region="center" style="overflow:hidden;">
</div>
</div>
</body>
</html>
var fireLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/MapServer",{id:'fire', visible:false});
... View more
07-08-2011
11:16 AM
|
0
|
0
|
481
|
|
POST
|
Hi Heming Thanks for your response. Yes I was looking at this sample and wondering how it can be implemented for a locator. I was confused as to how you would list the data in the grid particularly with the field headings as they are defined differently. If you look at this sample locator: http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Geocode_USA/GeocodeServer, AddressCandidate's attributes are came from Candidate Fields(or InterSection Candidate Fields) depending upon your address and outFields in addressToLocations(address, outFields?, callback?, errback?). So when you binding addresscandidate to data store, its fileds will automate populate in the data grid except for the identifier field which should be unique and explicitly specify(as i suggested using Reference data ID field(whichever that name is)....
... View more
07-08-2011
07:50 AM
|
0
|
0
|
2142
|
|
POST
|
Hi Manish, I only recently posted this (around an hour ago) so am still waiting for a response 🙂 There is a ESRI sample which binding an identify results to a data grid(http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/find_map_datagrid.html). The process is pretty similar. 1. map each of your AddressCandidate.attributes to items(an array). 2. Create a data object that contains items. 3. Create data store and bind to grid. Note: When you create a locator in ArcMap Desktop, check the "Reference data ID" checkbox under Output Fields. In doing so, you can assign this Reference data ID as identifier in your data object. Later on when interact your datagrid and map, you can use this ID to connect the address points on the map with the records on the datagrid. Hope my explaination makes sense to you.
... View more
07-08-2011
05:44 AM
|
0
|
0
|
2142
|
|
POST
|
Nice find - thanks. The problem is that this also hides the X to close the infoWindow. Is there a way to hide the title bar, but keep the X? (I've already implemented the ESC key to close the infoWindow as discussed in a previous post, but I think there still should be a way to close it using the mouse). I am not sure how can you keep x while hide title bar. I think x and titlebar share one node. But you can work around by add a x in your content simulate the close function.
... View more
07-07-2011
05:26 AM
|
0
|
0
|
646
|
|
POST
|
Two quick thoughts: dojo.connect(locator, "onAddressToLocationsComplete"); Doesn't this require a callback? i.e. dojo.connect(locator, "onAddressToLocationsComplete", processResults); function processResults(addressCandidates) { //handle your processing here, i.e. zoom to, etc. } Also, in the API it lists both of these formats for the address: { Street: "<street>", City: "<city>", State: "<state>", Zone: "<zone>" } { street: "380 New York", city: "Redlands", state: "CA", zip: "92373" } (Note the difference in captialization...dunno if it bothers it or not, but it's a discrepancy I saw) Besides what Mark pointed out, looking at your locator: http://gis.hamiltoncounty.in.gov/ArcGIS/rest/services/Addresses/GeocodeServer. There are two address fields:FULL_ADDRESS and CITY. You need specify them (CITY optional). This is what your code should looks:
function init() {
....
locator = new esri.tasks.Locator("http://gis.hamiltoncounty.in.gov/ArcGIS/rest/services/Addresses/GeocodeServer");
dojo.connect(locator, "onAddressToLocationsComplete", processResults);
var address ={}; //or var address =new Object();
address.FULL_ADDRESS =FullAddressString;
address.CITY =CityString; //optional
locator.addressToLocations(address);
....
}
function processResults(addressCandidates)
{
//handle your processing here, i.e. zoom to, etc.
}
... View more
07-06-2011
10:49 AM
|
0
|
0
|
1158
|
|
POST
|
I have some code written to allow a user to update a particular field value (ID #) of an object in a service. Works great EXCEPT when the user selects either a geometry that was added as Circle in ArcMap, or a Polyline that has been symbolized using Proportional Symbols (which I need as it shows Pipelines in a rather nice fashion based on pipe diameter). I can select and "Identify" the geometries and retrieve the current field value, however, it will not Save a change. The error logged on the server while attempting to save/update a field value on a circle geometry is: Anyone with any ideas? I have a number of "Circle" geometries in the service representing a number of objects (pipe access hatches, circle lids on vaults, etc.) and don't want to have to recreate these objects. thx I don't think JS API suports Proportional Symbol. You might have to work around by using Class Breaks Renderer or Updating your feature layer but only display it in associated map service (see explanation on FeatureLayer's MODE_SELECTION)
... View more
07-06-2011
06:32 AM
|
0
|
0
|
495
|
|
POST
|
Take the simple infoWindow example and change the infoWindow title declaration to read: map.infoWindow.setTitle(null); Run this in FireFox or Chrome, click on the map and note that the infoWindow's title section is minimised (this is my desired outcome). In Internet Explorer 8 (in Document Mode: IE7 Standards), the title is blank but is not minimised. This is causing a problem in my site as I am inserting an HTML object into the infoWindow's contents, and it's showing scrollbars in IE (since the empty but maximised Title section is taking up space I need for the HTML object). If I add padding to accommodate this, it looks ugly in every browser except IE7. Is this a bug? Is there a way to force IE7 to minimise the Title section when it's empty? Thanks, Steve You can hide infoWindow title Bar by using map.infoWindow.hideTitleBar();
... View more
07-06-2011
05:10 AM
|
0
|
0
|
646
|
|
POST
|
HOW TO Remove the esri logo from the mapserver?
map = new esri.Map("map", {
extent: initExtent,
logo:false
});
... View more
07-06-2011
04:42 AM
|
0
|
0
|
412
|
|
POST
|
This is what I ended up with. I think height and width were the key.
cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);
cadastral.identifyParams = new esri.tasks.IdentifyParameters();
cadastral.identifyParams.tolerance = 0;
cadastral.identifyParams.returnGeometry = true;
cadastral.identifyParams.layerIds = [9];
cadastral.identifyParams.geometry = evt.mapPoint;
cadastral.identifyParams.mapExtent = cadastral.map.extent;
cadastral.identifyParams.height = cadastral.map.height;
cadastral.identifyParams.width = cadastral.map.width; Since I am identifying on a polygon layer, what should the tolerance be? I just figured 0 would be best for a polygon. Thanks for the help. tolerance is usually used for point geometry. I guess 0 would be OK for polygon.
... View more
07-05-2011
09:09 AM
|
0
|
0
|
1654
|
|
POST
|
Thanks for the tip! I'm going to give it a try now. But I have one quick question, how would I highlight the selected points/polygons if they were queried? Would I use showFeature? Does it support multiple features? The identifyResults are graphics array (points or polygons). Since you are not using featurelayer, You will have to design symbols yourself for the resulted graphics (hightlighted simple fill symbol for polygon and simple maryker symbols for different points etc), and add them on the map.graphics layer...
... View more
07-01-2011
11:45 AM
|
0
|
0
|
630
|
|
POST
|
I am new to the API and get stuck on something that seems very straightforward. I have three content panes in a bordercontainer. I use the region attribute to specify their locations on the page, but the specs seem to be ignored by the browser (tried on FireFox so far). No matter what locations I specified the browser always place the three content panes from top to bottom in the order the <div> elements appear in the HTML document. Any suggestions? Here is my HTML doc. Thanks a lot. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ancient Theaters in Italy</title> <link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css"> <style> #titlePane { width: auto; height: 50px } #timesliderPane { width: 60px; height: 50px; padding: 5px } </style> <script type="text/javascript" data-dojo-config="parseOnLoad: true; isDeBug: true" </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.3"> </script> <script type="text/javascript"> dojo.require("dijit.layout.ContentPane") dojo.require("dijit.layout.BorderContainer") dojo.require("dijit.layout.AccordionContainer") dojo.require("esri.map"); dojo.addOnLoad(init); var map; function init(){ map = new esri.Map("mapPane"); var basemapURL = "https://arcgis.its.carleton.edu/ArcGIS/rest/services/ItalyTheaters/MapServer" var basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapURL); map.addLayer(basemap); } </script> </head> <body class="claro"> <div id="pageContainer" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline'"> <!-- TOP TITLE PANE--> <div id="titlePane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'bottom'"> <h1 align="center">Ancient Theaters in Italy</h1> </div> <!--CENTER MAP PANE--> <div id="mapPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" style="width:900px; height:600px"> </div> <!--BOTTOM TIME SLIDER PANE--> <div id="timesliderPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'right'"> Time slider here </div> </div> </body> </html> In BorderContainer layout, top, center, bottom only honor height style not width; left and right panel only honor width style. See Attachment
... View more
07-01-2011
11:32 AM
|
0
|
0
|
1005
|
|
POST
|
I'm developing a web mapping application where the client specifically requested the ability to turn each layer on and off, while retaining the ability to select the visible features. Out of 17 total layers, 15 need to be selectable by the user using a "select by shape" tool. Of these 15, 11 are points and 4 are polygons. Now, what's the best way to handle these 15 layers? Do I need to create a esri.layers.FeatureLayer for each of these 15? Since I'm just selecting them, could I use esri.layers.querytask instead? Would I need to create a separate map service for each of these 15 as well? Has anybody been in this situation before where your application has multiple selectable layers? How do you organize them within your map service? I apologize for the ignorance, but this is my first project, and needless to say, it isn't small. Thanks, Andrew From what you described, in my opinion, the feasible approach would be put all layers in one map service and use identify task to do the search or selection. The advantage of using identify task is you only need send one request to the server and get all the results from layers, and you can use spatial filter-the shape you draw (IdentifyParameters.geometry =your drawn shape) to do the selection, and you only search limited area (map.extent -what are on the current map). Code Snippet:
var identifyTask = new esri.tasks.IdentifyTask(your_mapService_URL);
var identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 2;
identifyParams.returnGeometry = true;
identifyParams.layerIds = your_selectable_layerids;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParams.geometry =your_drawn_shape;
identifyParams.mapExtent =map.extent;
identifyParams.width = map.width;
identifyParams.height = map.height;
identifyTask.execute(identifyParams, function(identifyResults){
..... after identify logic go here....
});
... View more
07-01-2011
09:55 AM
|
0
|
0
|
630
|
| 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
|