POST
|
Fantastic, Robert. Many thanks. I see you even got the slider working, too, I need to put this side by side with my code so I can see where I stumbled, but it is good to know this is now working as I had hoped. Again, many thanks.
... View more
11-25-2015
12:59 PM
|
0
|
0
|
316
|
POST
|
Happy Thanksgiving week to all stateside (and beyond) and good day to everyone else. I am slowly teaching myself (with the help from the user community) the JS API. It seems for every two steps forward, I am taking a step back. Thanks to the insight of others, I was recently able to successfully associate a legend with a dropdown button. I decided to give this a whirl with Nliu's and got it working--sort of. Currently, it functions just fine. However, I wish to associate it with other widgets. When I include these, the TOC fails to appear. After stripping the code down to its bare minimum, I have discovered that whenever I include parser.parse(); it fails. However, when I comment it out, it works just fine. I had hoped that the inclusion of parseOnLoad: false, would solve my issues, but it did not. Obviously, I am making yet another newbie mistake. It is, nonetheless, important that I fix this so I can include with my other widgets--and also learn more about the JS API. I have condensed the code and stuck it in a single file below. Any assistance and guidance is greatly appreciated. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Toggle Legend</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
margin: 0;
}
#toc-wrapper {
position: absolute;
left: 25px;
top: 70px;
//bottom: 25px;
padding: 10px;
background-color: #fff;
}
#tocButton {
position: absolute;
left: 25px;
top: 25px;
//bottom: 185px;
padding: 10px;
background-color: #fff;
z-index: 100;
}
//classes to style the legend
.esriLegendLayerLabel{
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
color:red;
}
.esriLegendServiceLabel{
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
font-size: 12px;
color:green;
}
.esriLegendService{
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
font-size: 11px;
color: #33A7DE;
font-weight:bold;
}
</style>
<script>
var dojoConfig = {
parseOnLoad: false,
packages: [{
name: "agsjs",
"location": 'http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/build/agsjs' // for xdomain load
}]
};
</script>
<script src="http://js.arcgis.com/3.14/"></script>
<script>
require([
"esri/map",
"esri/config",
"esri/layers/FeatureLayer",
"esri/InfoTemplate",
"esri/renderers/UniqueValueRenderer",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"dojo/fx/Toggler",
"dojo/fx",
"dojo/_base/array",
"dojo/dom",
"dojo/dom-geometry",
"dojo/on",
"dojo/parser",
"dijit/registry",
"agsjs/dijit/TOC",
"dojo/domReady!"
], function(
Map,
esriConfig,
FeatureLayer,
InfoTemplate,
UniqueValueRenderer,
SimpleMarkerSymbol,
Color,
Toggler,
coreFx,
arrayUtils,
dom,
domGeom,
on,
parser,
registry,
TOC
) {
//parser.parse(); //Doesn't seem to work with Nianwie's TOC. I don't understand why; remove it and the toolbar disappears!!!
var map = new Map("map", {
basemap:"gray",
center: [-98.435731, 35.222876],
zoom: 7,
logo: false,
slider: false
});
var np = new FeatureLayer("//services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NationalParkStats2013/FeatureServer/0");
var renderer = new UniqueValueRenderer(null, "Type");
var symbol1 = new SimpleMarkerSymbol();
symbol1.setColor(new Color("#ed5151"));
renderer.addValue("National Park", symbol1);
var symbol2 = new SimpleMarkerSymbol();
symbol2.setColor(new Color("#149ece"));
renderer.addValue("National Monument", symbol2);
np.setRenderer(renderer);
map.addLayers([np]);
//add the legend Superfluous with TOC
/* 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 legend = new Legend({
map: map,
layerInfos: layerInfo
}, "legend");
legend.startup();
}
});*/
// Add Table of Contents
map.on('layers-add-result', function (evt) {
try {
var toc = new TOC({
map: map,
layerInfos: [{
layer: np,
title: "National Parks",
//noLegend:true, IF DON'T WANT TO SHOW LEGEND
slider: true //This doesn't appear to work with FeatureLayers!!!
}]
}, "toc");
toc.startup();
toc.on("load", function () {
console.log("TOC loaded");
});
}
catch (e) { console.error(e.message); }
});
var isClicked = true; //this, along with display none set in the div style ensure it is not shown by default
var tocToggler = new Toggler({
node: "toc-wrapper",
showFunc: coreFx.wipeIn,
hideFunc: coreFx.wipeOut
});
on(dom.byId("tocButton"), "click", function(e){
if(isClicked===false){
tocToggler.hide();
isClicked=true;
}
else{
tocToggler.show();
isClicked=false;
}
});
});
</script>
</head>
<body>
<button type="button" id="tocButton" title="Hide/Show Layer List">Toggle Layer List</button>
<div id="map"></div>
<div id="tocDiv"></div>
<div id="toc-wrapper" style="display: none;">
<div id="toc" dojoType="dijit.layout.ContentPane" style="overflow:auto;width:275px;height:350px;vertical-align:top;"></div>
</div>
</body>
</html>
... View more
11-25-2015
10:04 AM
|
0
|
2
|
3020
|
POST
|
I posted a similar question in another thread regarding dojo/fx/toggle. Interestingly, this question was answered in that thread by @Robert Scheitlin, GISP. I will provide his solution below. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>Toggle Legend</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
<style>
html,
body,
#map {
height: 100%;
margin: 0;
}
#legend {
padding: 10px;
background-color: #fff;
}
#dropDownButtonContainer {
position: absolute;
top: 25px;
left: 25px;
z-index: 100;
}
</style>
<script src="http://js.arcgis.com/3.14/"></script>
<script>
require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/renderers/UniqueValueRenderer",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"esri/dijit/Legend",
"dijit/form/DropDownButton",
"dojo/dom",
"dojo/on",
"dojo/parser",
"dojo/domReady!"
], function (
Map,
FeatureLayer,
UniqueValueRenderer,
SimpleMarkerSymbol,
Color,
Legend,
DropDownButton,
dom,
on,
parser
) {
parser.parse();
var map = new Map("map", {
basemap: "gray",
center: [-98.435731, 35.222876],
zoom: 7,
logo: false,
slider: false
});
var layer = new FeatureLayer("//services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NationalParkStats2013/FeatureServer/0");
var renderer = new UniqueValueRenderer(null, "Type");
var symbol1 = new SimpleMarkerSymbol();
symbol1.setColor(new Color("#ed5151"));
renderer.addValue("National Park", symbol1);
var symbol2 = new SimpleMarkerSymbol();
symbol2.setColor(new Color("#149ece"));
renderer.addValue("National Monument", symbol2);
layer.setRenderer(renderer);
map.addLayer(layer);
var legend = new Legend({
map: map,
layerInfos: [{
layer: layer,
title: "National Park Statistics 2013"
}]
}, "legend");
legend.startup();
var myButton = new DropDownButton({
label: "Legend",
dropDown: legend
});
dom.byId("dropDownButtonContainer").appendChild(myButton.domNode);
});
</script>
</head>
<body class="claro">
<div id="legend" style="display: none;"></div>
<div id="dropDownButtonContainer"></div>
<div id="map"></div>
</body>
</html>
... View more
11-18-2015
07:14 AM
|
0
|
0
|
294
|
POST
|
Thank you very much. I will attempt both of these and report back on my findings. I greatly appreciate the assistance. Todd Todd Fagin Oklahoma Natural Heritage Inventory/ Department of Geography and Environmental Sustainability
... View more
11-18-2015
06:50 AM
|
0
|
0
|
430
|
POST
|
The other day, I posted a question about hiding/showing a legend using a dropdown control. An individual elsewhere suggested I should merely hide/show the legend div using a toggler. I have subsequently successfully implemented a very basic example of hiding/showing a div using dojo/fx/Toggler. However, when I attempt to implement it with the ArcGIS API for Javascript, it doesn't work. I am fairly certain I am likely overlooking the obvious or otherwise making a newbie mistake. I have posted my code example below (I have not attempted to really style it). Any assistance would be greatly appreciated. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Toggle Legend</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
margin: 0;
}
#legend-wrapper {
position: absolute;
left: 25px;
bottom: 25px;
padding: 10px;
background-color: #fff;
}
#legendButton {
position: absolute;
left: 25px;
bottom: 185px;
padding: 10px;
background-color: #fff;
z-index: 100;
}
</style>
<script src="http://js.arcgis.com/3.11/"></script>
<script>
require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/renderers/UniqueValueRenderer",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"esri/dijit/Legend",
"dojo/fx/Toggler",
"dojo/fx",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
], function(Map,
FeatureLayer,
UniqueValueRenderer,
SimpleMarkerSymbol,
Color,
Legend,
Toggler,
coreFx,
arrayUtils,
dom,
on
) {
var map = new Map("map", {
basemap:"gray",
center: [-98.435731, 35.222876],
zoom: 7,
logo: false,
slider: false
});
var layer = new FeatureLayer("//services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NationalParkStats2013/FeatureServer/0");
var renderer = new UniqueValueRenderer(null, "Type");
var symbol1 = new SimpleMarkerSymbol();
symbol1.setColor(new Color("#ed5151"));
renderer.addValue("National Park", symbol1);
var symbol2 = new SimpleMarkerSymbol();
symbol2.setColor(new Color("#149ece"));
renderer.addValue("National Monument", symbol2);
layer.setRenderer(renderer);
map.addLayer(layer);
var legend = new Legend({
map: map,
layerInfos: [{
layer: layer,
title: "National Park Statistics 2013"
}]
}, "legend");
legend.startup();
var isClicked = false;
var legendToggler = new Toggler({
node: "legend-wrapper",
showFunc: coreFx.wipeIn,
hideFunc: coreFx.wipeOut
});
on(dom.byId("legendButton"), "click", function(e){
if(isClicked===false){
legendToggler.hide();
isClicked=true;
}
else{
legendToggler.show();
isClicked=false;
}
});
});
</script>
</head>
<body>
<button type="button" id="legendButton">Toggle Legend</button>
<div id="map"></div>
<div id="legend-wrapper">
<div id="legend"></div>
</div>
</body>
</html>
... View more
11-18-2015
05:26 AM
|
0
|
3
|
3374
|
POST
|
Greetings, I am very new to the ArcGIS API for Javascript and am by no means a programmer. Nonetheless, I have been fairly successful at finding existing code and modifying it to my needs. That is, until now. I want something that I think should be simple and straightforward. However, despite looking high and low, I cannot find a good code sample. I would like a button that, when clicked, shows or hides a legend (or TOC). Indeed, I have seen multiple examples of this in WebAppBuilder applications and elsewhere, but it has not been easy to tease through the code. Surely, some others have done this. It seems to me that my answer should be in "dijit/form/DropDownButton." However, this newbie cannot seem to get it to work. My guess is I am overlooking the obvious (or, perhaps, I am approaching it all wrong). Your assistance would be greatly appreciated. I have attached an example of my failed attempt. Thanks in advance.
... View more
11-13-2015
01:57 PM
|
0
|
1
|
2682
|
POST
|
We can go back and forth on this with no resolution because it is all a matter of opinion. I was able to easily solve my problem by using a freely available, online batch geocoder. For the scale needed, this worked perfectly well, regardless of how annoying the diminished functionality in ArcGIS is. If I am working at larger geographic scales, I can easily build my own address locator using better source data. There are also numerous non-Esri tools available that enable me to geocode. There was a time when I could not say that, when GIS professionals were primarily restricted to one software unless they worked in a particular niche market. And for the non-professionals who may need to occasionally geocode. Sure, I can tell them to buy expensive software, then purchase expensive credits to use a particular geocode service or I can tell them there are alternative solutions that, in the end, may be significantly cheaper. Todd Fagin Oklahoma Natural Heritage Inventory/ Department of Geography and Environmental Sustainability
... View more
09-25-2014
02:45 PM
|
0
|
1
|
265
|
POST
|
I, of course, understand that things cost money, that is far from the point I am making. I am making a point of Esri’s once mighty empire crumbling as it becomes painfully obvious to many that its business model is untenable in this day and age. Todd Fagin Oklahoma Natural Heritage Inventory/ Department of Geography and Environmental Sustainability
... View more
09-25-2014
12:56 PM
|
0
|
3
|
265
|
POST
|
I have been using Esri products since the late 1990s. I am also aware of many other products on the market, both proprietary and open source. Believe, I know what I am talking about when I saw Esri is gauging its customers. It could get away with this when it was the only player on the market. That is no longer the case. It is just another reason I am running, not walking from this company to whom I have been a loyal customer for more than 15 years. Todd Fagin Oklahoma Natural Heritage Inventory/ Department of Geography and Environmental Sustainability
... View more
09-25-2014
12:50 PM
|
0
|
5
|
265
|
POST
|
In a nutshell, this is a problem. Previously, Esri made its default address locator available for free. It was very useful if you were needing a quick answer to a problem. For instance, if you have to geocode in a very large area, it is easier to use a canned geocoding service rather than building your own based on available data. It wasn’t perfect, but it worked. Esri makes a lot of money off its customers already. This is just another way for it to gauge us. It is getting to the point of being ridiculous. Todd Fagin Oklahoma Natural Heritage Inventory/ Department of Geography and Environmental Sustainability
... View more
09-25-2014
12:37 PM
|
0
|
7
|
507
|
POST
|
I would assume our educational subscription should be "free" since we have a campus-wide license. This begs the question of how I would check this and how I would go about using this account? I am still flummoxed as to what Esri hopes to achieve with this business model when such services are freely and readily available elsewhere. I am left shaking my head in disbelief.
... View more
09-25-2014
09:14 AM
|
0
|
2
|
507
|
POST
|
I am trying to use the World Geocode Service to batch geocode addresses across the U.S. However, whenever I do so, I get the following error message: "There was an error trying to process this table. ArcGIS Online subscription is required for geocoding the table of addresses." The problem is that I am actually logged into ArcGIS Online when this happens (see image). Perhaps I have the wrong subscription type?! I can't tell though, despite my efforts to figure this out. This is especially annoying for multiple reasons, among them. 1. It worked in previous versions of the software; 2. There are free batch geocoders online; and 3. There are other desktop solutions (e.g. QGIS with the Nominatim and Google web services) that are fully functional. As an educator and an individual who promotes GIS solutions, I am finding it increasingly difficult to promote Esri products, especially when something as basic and near universal as geocoding is not properly functioning. I implore Esri to fix this.
... View more
09-25-2014
08:36 AM
|
0
|
16
|
3319
|
POST
|
I found the answer to my question about the FeatureClassID. It is actually easy to determine once you know where to look: http://resources.arcgis.com/en/help/main/10.1/index.html#//0047000001rz000000 Knowing this fixed my problems. Many thanks. Todd Fagin Oklahoma Natural Heritage Inventory/ Department of Geography and Environmental Sustainability
... View more
08-15-2014
09:03 AM
|
1
|
0
|
541
|
POST
|
Thank you for the reply. I have been out of the office and haven’t been able to give this a try yet. I will first thing tomorrow. Again, many thanks.
... View more
08-14-2014
09:49 PM
|
0
|
0
|
541
|
POST
|
Greetings all, I am trying to build a Network Dataset with historic traffic data. (The traffic data are actually completely fictitious designed solely for the purposes of trying to learn how to configure a network dataset). The best I can tell both my tables and feature class are configured properly (with the exception of EdgeFCID--I have not idea how to determine the feature class ID; I only have one feature class participating in the network, though, so I went with 1 since that was the value the tutorial data used). When I build the dataset, I receive the following message: SourceName: Streets_DailyProfiles, ObjectID: 6, Network edge not found with positions 0.000000 to 1.000000. It then replicates this error for every ObjectID for which I have configured the daily profiles. Any suggestions on why this is and how to fix it would be greatly appreciated. Many thanks in advance, Todd
... View more
08-13-2014
12:17 PM
|
0
|
4
|
3784
|
Title | Kudos | Posted |
---|---|---|
1 | 05-12-2022 06:53 AM | |
1 | 01-18-2022 09:30 AM | |
1 | 01-14-2022 06:58 PM | |
6 | 04-27-2023 02:46 PM | |
1 | 04-05-2023 12:45 PM |
Online Status |
Offline
|
Date Last Visited |
12-01-2023
02:11 PM
|