|
POST
|
As I continued to search for a solution to this issue, I came across an older post and a solution by @RobertScheitlin__GISP that does, more or less, what I want. However, it was written for 3.23. I am trying to get it to week with 4.22, though, because it will be part of a larger project that is otherwise functioning well. In a nutshell, I would like to use the search widget to perform a search and query a feature layer based on the results of this search. For instance, say I have a PLSS layer and when one enters an address or set of coordinates, the PLSS layer is queried at that search location and the pop-up returns the PLSS attributes associated with that location. I hope to solve this first, but to add a little more complexity to the issue, I am actually searching multiple sources. Searching by multiple layer sources works great when the appropriate search term is entered (e.g. township, range, and section) information, but I essentially want a reverse geocode type solution in which someone types an address or enters coordinates and the PLSS layer is queried at that location and those results are returned. At issue (among many other things) is I am not particularly savvy when it comes to JS. I can take others' code and modify it to my needs, but that is the extent of it--so I basically need a lot of handhold. Below is the code I have working that includes everything except the spatial query. The feature layers I am using in it are just place holders and are not the ones I will actually be using going forward (so the attributes that pop up are a bit nonsensical at the moment). <html>
<head>
<meta name="description" content="DevLav: Query a feature layer">
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>PLSS Coordinate Calculator</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
.esri-view:fullscreen {
background-color: #fff;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.22/esri/css/main.css">
<script src="https://js.arcgis.com/4.22/"></script>
</head>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/widgets/CoordinateConversion",
"esri/layers/GroupLayer",
"esri/layers/FeatureLayer",
"esri/layers/MapImageLayer",
"esri/widgets/Home",
"esri/widgets/Search",
"esri/widgets/BasemapGallery",
"esri/widgets/LayerList",
"esri/widgets/Expand",
"esri/renderers/SimpleRenderer",
"esri/geometry/Extent",
"esri/geometry/SpatialReference",
"esri/tasks/support/Query",
"esri/tasks/QueryTask",
"esri/Graphic",
"esri/widgets/Fullscreen"
],
function(
Map,
MapView,
CoordinateConversion,
GroupLayer,
FeatureLayer,
MapImageLayer,
Home,
Search,
BasemapGallery,
LayerList,
Expand,
SimpleRenderer,
Extent,
SpatialReference,
Query,
QueryTask,
Graphic,
Fullscreen
) {
//map extent: Need this since no basemap; otherwise extent is pretty wonky
var bounds = new Extent({
"xmin":-103.5,
"ymin":33.0,
"xmax":-93.5,
"ymax":37.5,
"spatialReference":{"wkid":4326} //this is for the extent only; need to set map spatial reference in view.
});
// Oklahoma Counties Layer
var okcounties = new FeatureLayer({
url: "https://obsgis.csa.ou.edu:6443/arcgis/rest/services/ONHI/ArcGISServer_Counties/FeatureServer",
title: "Oklahoma Counties",
});
var trtemplate = {
// autocasts as new PopupTemplate()
title: "<strong>{label2} Centroid</strong>:",
content: "DD Centroid: {label2}<br> Level II Ecoregion: {label2}<br> Level I Ecoregion: {label2}"
};
// Township/Range
var townships = new FeatureLayer({
url: "https://obsgis.csa.ou.edu:6443/arcgis/rest/services/ONHI/PLSS/MapServer/0/",
outFields: ["*"],
title: "Township/Range"
//popupTemplate: template
});
// Sections
var sections = new FeatureLayer({
url: "https://obsgis.csa.ou.edu:6443/arcgis/rest/services/ONHI/PLSS/MapServer/1/",
outFields: ["*"],
title: "Section"
//popupTemplate: template
});
// Create GroupLayer for PLSS data
var PLSS = new GroupLayer({
title: "PLSS Data",
visible: false,
visibilityMode: "independent",
layers: [townships, sections]
});
var map = new Map({
//basemap: "satellite",
layers: [PLSS, okcounties]
});
var view = new MapView({
container: "viewDiv",
map: map,
//center: [-98.762150, 35.287798],
//zoom: 8,
extent: bounds,
spatialReference: 3857 //spatial reference of map; different from the extent
});
//Home button
var homeBtn = new Home({
view: view
});
// Add the home button to the top left corner of the view
view.ui.add(homeBtn, "top-left");
// create a search widget
var searchWidget = new Search({
view: view,
sources: [{
layer: new FeatureLayer({ //Notice the property is called layer Not featureLayer new to 4.11
url: "https://obsgis.csa.ou.edu:6443/arcgis/rest/services/ONHI/PLSS/MapServer/0/",
popupTemplate: trtemplate,
//{ // autocasts as new PopupTemplate()
//title: "{label2}",
// overwriteActions: true
//}
}),
searchFields: ["label2"],
displayField: "label2",
exactMatch: false,
outFields: ["label2"],
name: "Township/Range",
placeholder: "example: 12N 10W IM",
},
{
layer: new FeatureLayer({ //Notice the property is called layer Not featureLayer new to 4.11
url: "https://obsgis.csa.ou.edu:6443/arcgis/rest/services/ONHI/PLSS/MapServer/1/",
popupTemplate: { // autocasts as new PopupTemplate()
title: "{str_label2}",
overwriteActions: true
}
}),
searchFields: ["str_label2"],
displayField: "str_label2",
exactMatch: false,
outFields: ["str_label2"],
name: "Section Township/Range",
placeholder: "example: Sec. 15 12N 10W IM",
},
{
layer: new FeatureLayer({ //Notice the property is called layer Not featureLayer new to 4.11
url: "https://obsgis.csa.ou.edu:6443/arcgis/rest/services/ONHI/ArcGISServer_Counties/FeatureServer/0",
popupTemplate: { // autocasts as new PopupTemplate()
title: "{name} County",
overwriteActions: true
}
}),
searchFields: ["name"],
displayField: "name",
exactMatch: false,
outFields: ["name"],
name: "Counties",
placeholder: "example: Adair",
}]
});
// Add the search widget to the top right corner of the view
view.ui.add(searchWidget, {
position: "top-right"
});
// Create a BasemapGallery widget instance and set
// its container to a div element
var basemapGallery = new BasemapGallery({
view: view,
container: document.createElement("div")
});
// Create an Expand instance for basemap gallery
var bgExpand = new Expand({
view: view,
expandTooltip: "Select basemap",
content: basemapGallery
});
// Add the expand instance to the ui
view.ui.add(bgExpand, "top-left");
// Add a legend instance to the panel of a
// ListItem in a LayerList instance
const layerList = new LayerList({
view: view,
listItemCreatedFunction: function(event) {
const item = event.item;
if (item.layer.type != "group")
{ // don't show legend twice
item.panel = {
content: "legend",
open: false
};
}
}
});
// Create an Expand instance for legend gallery
var lgExpand = new Expand({
view: view,
expandTooltip: "Expand Layer List",
content: layerList
});
// Add the expand instance to the ui
view.ui.add(lgExpand, "top-left");
fullscreen = new Fullscreen({
view: view
});
view.ui.add(fullscreen, "top-right");
//Coordinate Conversion Widget
const ccWidget = new CoordinateConversion({
view: view
});
view.ui.add(ccWidget, "bottom-left");
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
01-21-2022
01:56 PM
|
0
|
0
|
5004
|
|
POST
|
Thank you. I have, indeed, seen this and it is what I am using to search on multiple data sources. Here's my quandary. Say someone searches on a census tract layer by some value. This isn't a problem--the maps zooms to that tract and the popup appears. However, let's say someone just enters a street address or a lat,lon. The maps will zoom to that location, but there is a default popup with the entered search (e.g. address or lat, lon). I want the popup to show the census tract information at that location. Of course, the user can get it with an additional click, I just want it to be seamless. I am not actually using census tract data, that was just my example. I am actually using PLSS data. So, if someone searches by a PLSS layer, say Section-Township-Range (STR), they will be returned with various attributes in a popup associated with that STR. However, they may not know the STR information, but have coordinates and search by that. If so, I want the popup to show the STR attributes associated with that set of coordinates. Hopefully, that makes sense. Many thanks.
... View more
01-18-2022
09:30 AM
|
1
|
1
|
5023
|
|
POST
|
I am looking for some sample code to create a custom pop-up for search results. I have found an old thread to override the default search results pop-up, but I would like it to be dynamically populated based on attributes of a intersected features. I thought I had seen something like this before, but for the life of me cannot find it. For example, let's say I have a census tracts feature layer with basic demographic information. When I enter an address into the search widget textbox, I would like the pop-up box to show these attributes from the feature layer for the census tract that the entered address intersects. Added bonus, if the custom text box also has the search string, so, for instance, the searched address or coordinates or whatever. E.G. 100 E. Main St. is in Census Tract XX with a Population of X or whatever. Thanks in advance. Todd
... View more
01-14-2022
06:58 PM
|
1
|
8
|
5571
|
|
POST
|
I am working with an individual who has a feature layer that was created with published Survey123 survey. He is then using this feature layer in a web app that includes the situational awareness widget. Though I do not completely understand his workflow, I know he is trying to save buffers created with the situation awareness tool to the Survey123 feature layer. However, this never works. What is odd, though, is if I just try to directly edit the exact same feature layer (e.g. using the Edit widget), it works fine. Any insight as to why the situation awareness won't save to a Survey123 feature layer, but regular editing can?
... View more
12-13-2021
07:53 PM
|
0
|
0
|
496
|
|
POST
|
Hi Brandon, I am not the best person to ask this. If I recall (it’s been a while), we upped our max to 5000. If there is an upper limit, I don’t know. I apologize I cannot be of more help. Todd
... View more
03-03-2020
05:13 PM
|
0
|
0
|
4724
|
|
POST
|
UGH. It is always the ridiculously simple solutions that I overlook. I was trying to figure out if there was something wrong with my map, with my feature service, the way it was published, etc., and all I had to do was create a group. Welp, as you know, that's correct. All is working now. Thank you.
... View more
12-05-2019
01:39 PM
|
1
|
0
|
1159
|
|
POST
|
I have a created a simple map with a feature service for use in Collector. Both the feature service and the map are shared with "ArcGIS Enterprise." All of the parameters are set properly to work with Collector, as well. If I log in to Collector, I can access my map and collect features. However, if anyone else logs into our Portal via Collector, they cannot access the map. Obviously, the map is configured properly for Collector since I can use it. How can I ensure that other users can access it as well? (I have tried searching for this answer and only come up with things that do not solve the issue.) Thank you, Todd
... View more
12-05-2019
12:43 PM
|
0
|
2
|
1203
|
|
POST
|
Hi Chris, I did. And it was convoluted and honestly don't recall how I eventually figured it out. Nonetheless, I had to do it again, struggled through it by memory, and finally wised up and wrote down my steps. These notes were written for one person in mind (myself), but perhaps they will help you, too. I have removed the service URLs (and if you use a different port, you will need to update that, too, of course), but these are otherwise my notes verbatim: 1. Go here: https://[server url]:6443/arcgis/admin/ 2. Generate token for https://[hosted layer url] 3. Go to https://[server url]:6443/arcgis/admin/ and login with generated token 4. Once logged in, go to services 5. Click the correct service 6. Enter the following URL: https://[hosted layer url]/edit 7. Change "maxRecordCount": 1000, to another value, e.g. "maxRecordCount": 5000, 8. Save the edits Side note: for step one, you may be able to go directly to https://[server url]/portal/sharing/rest/generateToken to generate the token. Hopefully, my notes will be of use to you. Todd
... View more
10-10-2019
04:08 AM
|
1
|
1
|
5228
|
|
POST
|
It appears the work around is that once the extent is set, you have to hit the full extent button and then it adjusts.
... View more
10-01-2019
10:51 AM
|
0
|
0
|
1039
|
|
POST
|
I am trying to do something that should be ridiculously simple. I have a project with multiple maps. I would like all the maps to be at the exact same extent and scale. I open the map properties, I click the extent tab, click the use custom extent tab, copy the the extent, and then repeat and paste the extent coordinates into a different map. Nothing happens. The map extent remains exactly as it was before. Why?
... View more
10-01-2019
10:40 AM
|
0
|
1
|
1133
|
|
POST
|
They are using Samsung Galaxy Tabs 10.1 with built in GPS.
... View more
08-13-2019
01:44 PM
|
0
|
0
|
882
|
|
POST
|
I created a survey with repeats using Survey123 for some field inspectors. Several of the inspectors are experiencing odd behavior and I am wondering if there may be a solution to this. I will translate the problem as described to me. However, since I am not the one experiencing the problems, I may miss some details. Additionally, the problem is being described by an individual who isn't necessarily tech-savvy. The field inspector goes into the field and updates an existing feature (repeat); After entering the updated information, s/he will select the Send Later option; The inspector will then drive to the next location and, based on the description given me, the "blue flashing dot" (current location) will show the features in the vicinity, which then "all turn orange then flash completely off the map and then slowly build back and my blue dot catches up to me until I update my next [feature]." Again, this is how it was explained to me. The main issues, best I can tell, are the current location point disappearing and the features turning orange, disappearing, and slowly reappearing. I know it is sufficiently vague, but all I have to work with at the moment. Thank you.
... View more
08-12-2019
10:43 AM
|
0
|
2
|
908
|
|
POST
|
I have tested this and it works. I don't find it to be the optimal solution, but it is better than nothing. I do, however, very much like the ribbon idea so that I do not have to launch the data inspector from a shortcut or from the directory.
... View more
08-12-2019
07:06 AM
|
1
|
0
|
1436
|
|
POST
|
Bruce, While it might be true that more individuals are moving away from file-based formats, they are still used extensively. For instance, there are occasions when I will have a GeoJSON file and all I need to do is open and inspect it (there are a variety of reasons for this--one of which is to ensure the GeoJSON file I created is working correctly. For instance, I will get requests for GeoJSON files from time to time). In such an instance, converting the file to an Esri-compatible format is self-defeating. Fortunately, I can just use ArcMap or even QGIS for this, though my desire would be really to stay within one environment at a time (and, sadly, the Pro conversion tool, which projects to WGS 84 and supports aliases, is superior to ArcGIS Desktop's Feature to JSON tool). Todd
... View more
08-09-2019
02:57 PM
|
0
|
2
|
1436
|
|
POST
|
While I appreciate the reply, this begs the question of what, then, is the point of the Data Interoperability extension? This is so maddening. There are times I cannot help but think Esri really doesn't want people to adopt ArcGIS Pro.
... View more
08-09-2019
01:19 PM
|
4
|
8
|
6435
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-12-2025 12:15 PM | |
| 1 | 11-14-2024 12:18 PM | |
| 1 | 11-13-2024 01:18 PM | |
| 1 | 06-13-2024 03:06 PM | |
| 1 | 05-12-2022 06:53 AM |
| Online Status |
Offline
|
| Date Last Visited |
06-13-2025
12:44 PM
|