POST
|
That helped indeed. I think that I see my error - I was confused & didn't think that I had to initialize a template variable. Thank you!
... View more
10-19-2020
08:21 AM
|
0
|
0
|
517
|
POST
|
Hi Robert, Thanks for the answer. That makes sense - I suppose that I was under the impression that referencing the variable popupCustom with popupTemplate within the Cyber_Areas featurelayer declaration would associate the search widget popup information with that of Cyber_Areas. That being said, I'm a JS beginner, & am uncertain of how I can properly reference my feature layer. Do you know if it is it still possible using popupTemplate, & if so what I would need to add/look into? Or if the popupTemplate class will not work out for my purposes, what might? p.s. the custom search widget text code (amongst many other troubleshooting answers I found related to Arc API) were answered by you - thanks for all of your help!
... View more
10-19-2020
06:40 AM
|
0
|
2
|
517
|
POST
|
The content in the popup created through the variable "popupCustom" is displaying string instead of referencing the specified field {IN_COUNTRY}. I followed the ArcGIS JS API Popup Tutorials, & can't see what my error is in failing to grab the attributes associated with that field. Here's the code -- any help is greatly appreciated! *note: feature layer url within "Cyber_Areas" variable points to REST URL for referenced Feature Class. <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Search widget with multiple sources - 4.6</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.6/esri/css/main.css">
<script src="https://js.arcgis.com/4.6/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/widgets/BasemapToggle",
"esri/widgets/Legend",
"esri/layers/TileLayer",
"esri/layers/FeatureLayer",
"esri/widgets/Search",
"esri/widgets/LayerList",
"esri/PopupTemplate",
"dojo/on",
"dojo/domReady!"
], function(
Map,
MapView,
BasemapToggle,
Legend,
TileLayer,
FeatureLayer,
Search,
LayerList,
PopupTemplate,
on
) {
var Cyber_Areas = new FeatureLayer({
url: "*inserturl*",
outFields: ["IN_COUNTRY"],
popupTemplate: popupCustom
});
var map = new Map({
basemap: "osm"
});
map.add(Cyber_Areas);
var view = new MapView({
container: "viewDiv",
map: map,
center: [-87.172865, 34.077613], // lon, lat
zoom: 16
});
var searchWidget = new Search({
view: view,
popupOpenOnSelect: false
});
view.ui.add(searchWidget, {
position: "top-left",
index: 0
});
var popupCustom = searchWidget.on('select-result', function(evt){
//console.info(evt);
view.popup.open({
location: evt.result.feature.geometry, // location of the click on the view
title: "Service Availability:", // title displayed in the popup
content: "<p><b>{IN_COUNTRY}"
});
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
10-16-2020
02:42 PM
|
0
|
4
|
601
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|