POST
|
Tracy, thanks. I think I have reached a point where I need to start over with a clean slate. It is my first venture into ArcGIS API for JavaScript and wanted to see how far I could take it before I got bogged down and thanks to the Forum, I have learned quite a bit. Thanks for taking a look at my code. I will look into your suggestions. Laura
... View more
05-15-2014
08:14 AM
|
0
|
0
|
475
|
POST
|
I am pretty sure I replicated your example. For some reason, my layers are not showing up. Any help would be appreciated! Here is the code:
var findTask, findParams;
var map, center, zoom;
var grid, store;
var highlightMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,255,0]), 2),new Color([255,255,0,0.5]));
var highlightFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,200,0]), 2), new Color([255,255,0,0.50]));
var popup = new Popup({
titleInBody: false,
fillSymbol: highlightFillSymbol,
markerSymbol: highlightMarkerSymbol
}, domConstruct.create("div"));
parser.parse();
center = [-69, 45.5];
zoom = 6;
map = new esri.Map("map", {
basemap : "topo",
center : center,
zoom : zoom,
infoWindow : popup
});
var scalebar = new Scalebar({
map: map,
scalebarUnit: "dual"
});
var home = new HomeButton({
map: map
}, "HomeButton");
home.startup();
map.on("load", function() {
findParams = new FindParameters();
findParams.returnGeometry = true;
findParams.layerIds = [0];
findParams.searchFields = ["ORG_NAME"];
findParams.outSpatialReference = map.spatialReference;
findParams2 = new FindParameters();
findParams2.returnGeometry = true;
findParams2.layerIds = [0];
findParams2.searchFields = ["org_name"];
findParams2.outSpatialReference = map.spatialReference;
findParams3 = new FindParameters();
findParams3.returnGeometry = true;
findParams3.layerIds = [0];
findParams3.searchFields = ["org_name"];
findParams3.outSpatialReference = map.spatialReference;
findParams4 = new FindParameters();
findParams4.returnGeometry = true;
findParams4.layerIds = [0];
findParams4.searchFields = ["org_name"];
findParams4.outSpatialReference = map.spatialReference;
});
function doFind() {
findParams.searchText = dom.byId("processorName").value;
findTask.execute(findParams, showResults);
}
function doFind2() {
findParams2.searchText = dom.byId("specialtyName").value;
findTask2.execute(findParams2, showResults);
}
function doFind3() {
findParams3.searchText = dom.byId("buyingclubName").value;
findTask3.execute(findParams3, showResults);
}
function doFind4() {
findParams4.searchText = dom.byId("farmName").value;
findTask4.execute(findParams4, showResults);
}
registry.byId("search").on("click", doFind);
registry.byId("search2").on("click", doFind2);
registry.byId("search3").on("click", doFind3);
registry.byId("search4").on("click", doFind4);
domClass.add(map.infoWindow.domNode, "myTheme");
var template = new InfoTemplate();
infoTemplate.setTitle("<b>${ORG_NAME}</b>");
infoTemplate.setContent( "${ADDRESS}<br/>"
+ "${CITY_TOWN}, ${STATE}<br/>"
+ "Phone: ${PHONE}"
);
var template2 = new InfoTemplate();
infoTemplate.setTitle("<b>${org_name}</b>");
infoTemplate.setContent( "${address}<br/>"
+ "${city_town}, ${state}<br/>"
+ "Phone: ${phone}"
);
var template3 = new InfoTemplate();
infoTemplate.setTitle("<b>${org_name}</b>");
infoTemplate.setContent( "${address}<br/>"
+ "${city_town}, ${state}<br/>"
+ "Phone: ${phone}"
);
var template4 = new InfoTemplate();
infoTemplate.setTitle("<b>${org_name}</b>");
infoTemplate.setContent( "${address}<br/>"
+ "${city_town}, ${state}<br/>"
+ "Phone: ${phone}"
);
var featureLayer = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/ProcessorsGIS428/MapServer/0",{
mode: FeatureLayer.MODE_SNAPSHOT,
id: "featureLayer",
outFields: ["*"],
infoTemplate: template
});
var query = new Query();
query.where = "1=1";
featureLayer.queryFeatures(query, function(featureSet) {
var nameList = [];
dojo.map(featureSet.features, function(feature) {
nameList.push(feature.attributes.ORG_NAME);
});
arrayUtils.forEach(nameList, function(feature){
registry.byId("processorName").get('store').add({ name: feature});
})
});
findTask = new FindTask("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/ProcessorsGIS428/MapServer");
var featureLayer2 = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/SpecFoodProdGIS428/MapServer/0",{
mode: FeatureLayer.MODE_SNAPSHOT,
id: "featureLayer2",
outFields: ["*"],
infoTemplate: template2
});
var query2 = new Query();
query2.where = "1=1";
featureLayer2.queryFeatures(query, function(featureSet) {
var nameList2 = [];
dojo.map(featureSet.features, function(feature) {
nameList2.push(feature.attributes.org_name);
});
arrayUtils.forEach(nameList2, function(feature){
registry.byId("specialtyName").get('store').add({ name: feature});
})
});
findTask2 = new FindTask("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/SpecFoodProdGIS428/MapServer");
var featureLayer3 = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/BuyingClubsGIS428/MapServer/0",{
mode: FeatureLayer.MODE_SNAPSHOT,
id: "featureLayer3",
outFields: ["*"],
infoTemplate: template3
});
var query3 = new Query();
query3.where = "1=1";
featureLayer3.queryFeatures(query, function(featureSet) {
var nameList3 = [];
dojo.map(featureSet.features, function(feature) {
nameList3.push(feature.attributes.org_name);
});
arrayUtils.forEach(nameList3, function(feature){
registry.byId("buyingclubName").get('store').add({ name: feature});
})
});
findTask3 = new FindTask("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/BuyingClubsGIS428/MapServer");
var featureLayer4 = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/FarmsGIS428/MapServer/0",{
mode: FeatureLayer.MODE_SNAPSHOT,
id: "featureLayer4",
outFields: ["*"],
infoTemplate: template4
});
var query4 = new Query();
query4.where = "1=1";
featureLayer4.queryFeatures(query, function(featureSet) {
var nameList4 = [];
dojo.map(featureSet.features, function(feature) {
nameList4.push(feature.attributes.org_name);
});
arrayUtils.forEach(nameList4, function(feature){
registry.byId("farmName").get('store').add({ name: feature});
})
});
findTask4 = new FindTask("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/FarmsGIS428/MapServer");
map.on("layers-add-result", function (evt) {
var layerInfo = arrayUtils.map(evt.layers, function (layer, index) {
return {layer:layer.layer, title:layer.layer.name};
});
if (layerInfo.length > 0) {
var legendDijit = new Legend({
map: map,
layerInfos: layerInfo
}, "legendDiv");
legendDijit.startup();
}
});
map.addLayers([featureLayer, featureLayer2, featureLayer3, featureLayer4]);
function showResults(results) {
map.graphics.clear();
console.log(results);
var symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 15,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_NULL, new Color([255, 0, 0, 1]), 1), new Color([255, 0, 0, 1])
);
var items = arrayUtils.map(results, function(result) {
var graphic = result.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
return result.feature.attributes;
});
var data = {
identifier : "Name",
label : "Name",
items : items
};
store = new ItemFileReadStore({
data : data
});
var grid = registry.byId("grid");
grid.setStore(store);
grid.on("rowclick", onRowClickHandler);
map.centerAndZoom(center, zoom);
}
function onRowClickHandler(evt) {
var clickedOrgName = evt.grid.getItem(evt.rowIndex).ORG_NAME;
var selectedOrgName = arrayUtils.filter(map.graphics.graphics, function(graphic) {
return ((graphic.attributes) && graphic.attributes.ORG_NAME === clickedOrgName);
});
if (selectedOrgName.length) {
var center = [selectedOrgName[0].geometry.getLongitude(), selectedOrgName[0].geometry.getLatitude()];
var zoom = 15;
map.centerAndZoom(center, zoom);
}
}
});
... View more
05-13-2014
04:23 PM
|
0
|
0
|
475
|
POST
|
Hate to say, but I am an ArcGIS API for JavaScript beginner. I tried to incorporate the code from the example you suggested and seem to have lost my layers. I commented out my old popup code as a reference. Perhaps someone can look at my code at www.laurateisl.com and give me some suggestions/hints as to how to move forward. I only added two of the feature layers to the new popup code to make sure I was doing this correctly (which I am not). Again, I'm a newbie....
... View more
05-13-2014
05:29 AM
|
0
|
0
|
475
|
POST
|
If you are zoomed out on my map, points overlap and I need my popups to list all of the layers (similar to ArcGIS Online maps, where the popup will list "1 of 4" if layers overlap.) My code is available at www.laurateisl.com. Also, some of my popups display beyond the extent of the map. Is there any way to restrict this behavior? Any advice would be appreciated. Thanks, Laura
... View more
05-13-2014
03:50 AM
|
0
|
7
|
922
|
POST
|
Thanks for spending time on this problem. Much appreciated. I will try your suggestion. Laura
... View more
05-12-2014
03:17 AM
|
0
|
0
|
667
|
POST
|
Thanks for asking. I did not fix the popup problem. My popups work except in this situation: If I perform a search (from the accordion container on the right) and obtain a result (a red point), when I click on the red point (the result of my search), I do not get a popup. I appreciate any input. Laura
... View more
05-08-2014
08:24 AM
|
0
|
0
|
667
|
POST
|
Chip, That worked nicely. Thank you. Nice reference. Laura
... View more
05-08-2014
07:15 AM
|
0
|
0
|
667
|
POST
|
I have a couple of nagging questions based on the code at www.laurateisl.com. 1) I can't seem to get my popup to work for the result of a search. 2) As my map/Web site loads, some ContentPane data flashes in the top left hand side of the webpage, then disappears. The code then correctly loads. Any suggestions for correcting either of this matters? Any help is appreciated. Thanks, Laura
... View more
05-08-2014
04:07 AM
|
0
|
7
|
957
|
POST
|
Thank you. Brilliant! And I will add any code between tags from now on. May I ask how you would add a drop down list of all possible "ownerName" so a user would not have to guess at the possible choices?
... View more
05-01-2014
10:13 AM
|
0
|
0
|
221
|
POST
|
Hello. I am attempting to use the "Show find task results in a Data Grid" with a service with a point layer. It is not working. Also, I would like all of the points to display initially. Again, the I am a JavaScript newbie and appreciate any input. Thanks. code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--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>Display Find Task results in Dojo DataGrid</title> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dojox/grid/resources/Grid.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dojox/grid/resources/claroGrid.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } </style> <script src="http://js.arcgis.com/3.9/"></script> <script> require([ "esri/map", "esri/tasks/FindTask", "esri/tasks/FindParameters", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/Color", "dojo/on", "dojo/dom", "dijit/registry", "dojo/_base/array", "dojo/_base/connect", "dojox/grid/DataGrid", "dojo/data/ItemFileReadStore", "dijit/form/Button", "dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!" ], function( Map, FindTask, FindParameters, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, Color, on, dom, registry, arrayUtils, connect, DataGrid, ItemFileReadStore, Button, parser ) { var findTask, findParams; var map, center, zoom; var grid, store; parser.parse(); registry.byId("search").on("click", doFind); center = [-69, 45.5]; zoom = 7; map = new esri.Map("map", { basemap: "topo", center: center, zoom: zoom }); //Create Find Task using the URL of the map service to search findTask = new FindTask("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/SpecFoodProdGIS428/MapServer/0"); map.on("load", function () { //Create the find parameters findParams = new FindParameters(); findParams.returnGeometry = true; findParams.layerIds = [0]; findParams.searchFields = ["org_name", "city_town", "Used_comb"]; findParams.outSpatialReference = map.spatialReference; console.log("find sr: ", findParams.outSpatialReference); }); function doFind() { //Set the search text to the value in the box findParams.searchText = dom.byId("org_name").value; findTask.execute(findParams, showResults); } function showResults(results) { //This function works with an array of FindResult that the task returns map.graphics.clear(); var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([98, 194, 204]), 2), new Color([98, 194, 204, 0.5]) ); //create array of attributes var items = arrayUtils.map(results, function (result) { var graphic = result.feature; graphic.setSymbol(symbol); map.graphics.add(graphic); return result.feature.attributes; }); //Create data object to be used in store var data = { identifier : "org_name", //This field needs to have unique values label : "Name", //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 ItemFileReadStore({ data : data }); var grid = registry.byId("grid"); grid.setStore(store); grid.on("rowclick", onRowClickHandler); //Zoom back to the initial map extent map.centerAndZoom(center, zoom); } //Zoom to the parcel when the user clicks a row - changed clickedTaxLotID to clickedOrgName - changed selectedTaxLot to selectedOrgName function onRowClickHandler(evt) { var clickedOrgName = evt.grid.getItem(evt.rowIndex).org_name; var selectedOrgName = arrayUtils.filter(map.graphics.graphics, function (graphic) { return ((graphic.attributes) && graphic.attributes.org_name === clickedOrgName); }); if ( selectedOrgName.length ) { map.setExtent(selectedOrgName[0].geometry.getExtent(), true); } } }); </script> </head> <body class="claro"> <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%;height:100%;margin:0;"> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'" style="height:40px;"> Owner name: <input type="text" id="ownerName" size="60" value="Northern Girl" /> <button id="search" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" >Search </button> </div> <div id="map" data-dojo-props="region:'center'" data-dojo-type="dijit/layout/ContentPane" style="border:1px solid #000;"></div> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'" style="height:150px;"> <table data-dojo-type="dojox/grid/DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'"> <thead> <tr> <th field="org_name">Name</th> <th field="city_town" >City</th> <th field="cont_pers">Contact</th> <th field="sp_prdcts">Products</th> <th field="Used-comb" width="100%">Products Used</th> </tr> </thead> </table> </div> </div> </body> </html>
... View more
05-01-2014
04:52 AM
|
0
|
3
|
334
|
POST
|
Thank you for replying. I will check and get back to you.
... View more
05-01-2014
03:09 AM
|
0
|
0
|
96
|
POST
|
I have a popup display question. Let's assume that I have no data in one of the "address" fields in the service. My popup will then have a space where that field data would have displayed. Is there code that will delete the space if there is no data in the field so the popup will be more nicely displayed?
... View more
04-30-2014
07:57 AM
|
0
|
0
|
542
|
POST
|
That did the trick! This is fun! Well, it is fun thanks to your help.
... View more
04-30-2014
07:16 AM
|
0
|
0
|
542
|
POST
|
What you both suggested worked! Thank you. I would like to build on the code by adding two more services. Now all three services correctly display in the legend. But I have an issue with the popups. Each service has the same three fields: org_name, address and state. The popup works correctly only for the first service listed: SpecialtyFoodProducers. But not for the remaining two. The popups "pop up," but the fields are not listed. Any ideas? Again, many thanks. code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--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>Map with legend</title> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css"> <style> html, body { font-family: Tahoma, Geneva, sans-serif; height: 97%; width: 98%; margin: 1%; } #rightPane { width: 20%; } #legendPane { border: solid #97DCF2 1px; } </style> <script src="http://js.arcgis.com/3.9/"></script> <script> require([ "esri/map", "esri/layers/FeatureLayer", "esri/dijit/Legend", "dojo/_base/array", "dojo/parser", "esri/dijit/InfoWindowLite", "esri/InfoTemplate", "dojo/dom-construct", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/layout/AccordionContainer", "dojo/domReady!" ], function( Map, FeatureLayer, Legend, arrayUtils, parser, InfoWindowLite, InfoTemplate, domConstruct ) { parser.parse(); var map = new Map("map", { basemap:"topo", center: [-69, 45.5], zoom: 7 }); var infoWindow = new InfoWindowLite(null, domConstruct.create("div", null, null, map.root)); infoWindow.startup(); map.setInfoWindow(infoWindow); var template = new InfoTemplate(); template.setTitle("<b>${org_name} - ${address}</b>"); template.setContent("${org_name} is in ${state}"); var SpecialtyFoodProducers = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/SpecFoodProdGIS428/MapServer/0", { mode: FeatureLayer.MODE_ONDEMAND, infoTemplate:template, outFields: ["org_name" , "address" , "state"] }); var Distributors = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/ProcessorsGIS428/MapServer/0", { mode: FeatureLayer.MODE_ONDEMAND, infoTemplate:template, outFields: ["org_name" , "address" , "state"] }); var BuyingClubs = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/BuyingClubsGIS428/MapServer/0", { mode: FeatureLayer.MODE_ONDEMAND, infoTemplate:template, outFields: ["org_name" , "address" , "state"] }); //add the legend map.on("layers-add-result", function (evt) { var layerInfo = arrayUtils.map(evt.layers, function (layer, index) { return {layer:layer.layer, title:layer.layer.name}; }); if (layerInfo.length > 0) { var legendDijit = new Legend({ map: map, layerInfos: layerInfo }, "legendDiv"); legendDijit.startup(); } }); map.addLayers([SpecialtyFoodProducers, Distributors, BuyingClubs]); map.infoWindow.resize(200, 75); }); </script> </head> <body class="claro"> <!--[if IE 7]> <style> html, body { margin: 0; } </style> <![endif]--> <div id="content" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters:true" style="width: 100%; height: 100%; margin: 0;"> <div id="rightPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'right'"> <div data-dojo-type="dijit/layout/AccordionContainer"> <div data-dojo-type="dijit/layout/ContentPane" id="legendPane" data-dojo-props="title:'Legend', selected:true"> <div id="legendDiv"></div> </div> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'Tools'"> This pane could contain tools or additional content </div> </div> </div> <div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" style="overflow:hidden;"> </div> </div> </body> </html>
... View more
04-30-2014
06:28 AM
|
0
|
0
|
542
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|