POST
|
Hello all, I have gotten the code to work with the following layer types: Map Services Feature Services OGC WMS Services* CSV Layers* KML Layers* Image Service Layers * = require a proxy to be set up. The Esri Resource Proxy can be used. Here is the code: (URL comes from a textbox) function getLayerType(url) {
var layerType;
if (url.includes("/FeatureServer"))
layerType = "FeatureServer";
else if ((url.includes("wms") || (url.includes("WMS"))) || (url.includes("/MapServer") && url.includes("WMS")))
layerType = "ogcWms";
else if (url.includes(".csv"))
layerType = "CSV";
else if (url.includes(".kml"))
layerType = "KML";
else if (url.includes("/ImageServer"))
layerType = "ImageServer";
else if (url.includes("/MapServer") && layerType != "ogcWms")
layerType = "MapServer";
addLayer(url, layerType);
}
function addLayer(layerURLValue, layerType) {
var date = getDate();
switch (layerType) {
case "FeatureServer":
console.log("Feature Service");
//Check to see if the URL ends with a number (for a specific sublayer), if it does not, load all sublayers.
var match = layerURLValue.match(/\d+$/);
if (match) {
var layersRequest = esriRequest({
url: layerURLValue,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
layersRequest.then(
function (response) {
console.log(response);
var popupTitle;
if (response.displayField)
popupTitle = "{" + response.displayField + "}";
else
popupTitle = response.name;
var layer = new FeatureLayer(layerURLValue, {
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
infoTemplate: new PopupTemplate({ title: popupTitle, description: "{*}" })
})
var mapLyrNam;
if (response.name)
mapLyrNam = response.name;
else
mapLyrNam = date;
var layerObj = {
id: mapLyrNam,
layer: layer,
};
addLyrToMap(layerObj, layer);
}, function (error) {
console.log("Error: Esri Request Failed. Feature Service Layer is unable to load. Error Message: ", error.message);
alert("Layer can not be added. See Console for details.");
});
//Load all sublayers
} else {
var layersRequest = esriRequest({
url: layerURLValue,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
layersRequest.then(
function (response) {
console.log(response);
response.layers.forEach(function (sublayer) {
var layer = new FeatureLayer(layerURLValue + "/" + sublayer.id, {
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
infoTemplate: new PopupTemplate({ title: sublayer.name, description: "{*}" })
})
var layerObj = {
id: sublayer.name,
layer: layer,
};
addLyrToMap(layerObj, layer);
});
}, function (error) {
console.log("Error: Esri Request Failed. Feature Service Layer is unable to load. Error Message: ", error.message);
alert("Layer can not be added. See Console for details.");
});
}
break;
case "MapServer":
console.log("Map Service");
var match = layerURLValue.match(/\d+$/);
if (match) {
alert("Unfortunatly, loading specific Sublayers for a Map Service is not currently supported. Please remove the specific sublayer from the end of the URL, and try again.");
break;
}
var layer;
var layerPopup = {};
var layersRequest = esriRequest({
url: layerURLValue,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
layersRequest.then(
function (response) {
console.log("Success: ", response);
var sublayerCounter = -1;
response.layers.forEach(function (sublayer) {
console.log(sublayer.name);
sublayerCounter++
layerPopup[sublayerCounter] = {
infoTemplate: new InfoTemplate(sublayer.name, "${*}"),
layerUrl: layerURLValue + "/" + sublayerCounter
}
});
layer = new ArcGISDynamicMapServiceLayer(layerURLValue, {
id: response.mapName,
infoTemplates: layerPopup
});
var mapLyrNam;
if (response.documentInfo == undefined || response.documentInfo.Title == "" || response.documentInfo.Title == undefined)
mapLyrNam = response.mapName;
else
mapLyrNam = response.documentInfo.Title;
var layerObj = {
id: mapLyrNam,
layer: layer,
};
addLyrToMap(layerObj, layer);
}, function (error) {
console.log("Error: Esri Request Failed. Map Service Layer is unable to load. Error Message: ", error.message);
alert("Layer can not be added. See Console for details.");
});
break;
case "ogcWms":
console.log("OGC Web Map Service");
var layer = new WMSLayer(layerURLValue, {
id: date
});
var layerObj = {
id: layer.id,
layer: layer
};
addLyrToMap(layerObj, layer);
break;
case "CSV":
console.log("CSV Layer");
var csvName = layerURLValue.substring(layerURLValue.lastIndexOf('/') + 1);
var layer = new CSVLayer(layerURLValue, {
id: csvName,
infoTemplate: new PopupTemplate({ title: csvName, description: "{*}" })
});
var layerObj = {
id: csvName,
layer: layer
};
addLyrToMap(layerObj, layer);
break;
case "ImageServer":
console.log("Image Service");
var layer;
var layersRequest = esriRequest({
url: layerURLValue,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
layersRequest.then(
function (response) {
layer = new ArcGISImageServiceLayer(layerURLValue);
var layerObj = {
id: response.name,
layer: layer,
};
addLyrToMap(layerObj, layer);
}, function (error) {
console.log("Error: Esri Request Failed. Image Service Layer is unable to load. Error Message: ", error.message);
alert("Layer can not be added. See Console for details.");
});
break;
case "KML":
console.log("KML");
var kmlName = layerURLValue.substring(layerURLValue.lastIndexOf('/') + 1);
var layer = new KMLLayer(layerURLValue, {
id: date
});
var layerObj = {
id: kmlName,
layer: layer
};
addLyrToMap(layerObj, layer);
break;
}
}
function addLyrToMap(layerObj, layer) {
mapInfoLyrs.push(layerObj);
map.addLayer(layer);
map.legendList.refresh();
} For clarification: The "mapInfoLyrs" array is used by the Esri "LayerList" to keep track of what layers are on the map. See this link for more details. The "legendList" object is the Esri "LayerList" widget. When a new layer is added to the map, it must be refreshed.
... View more
07-26-2018
09:05 AM
|
0
|
2
|
555
|
POST
|
Hello Andrew! Sorry for the delayed reserpine. I have been working on this on the side and have had to fix some issues. I will post what I have soon. The code that I have utilizes the 3.x JS API. Chris
... View more
07-16-2018
12:10 PM
|
0
|
0
|
1939
|
POST
|
If your app is being sold for profit, then you would need the ArcGIS Online deployment Plan. However, If you already have an ArcGIS Online Organization, you do not need to purchase the deployment plan. See: Terms of Use - FAQ | ArcGIS for Developers You may be able to supplement buying the ArcGIS Deployment Plan if you have an ArcGIS Enterprise License as well. I am not sure on this. As Robert Scheitlin, GISP suggested above, it would be best to contact Esri directly to seek answers to these questions. Esri's Licensing can be quite confusing at times. I hope this helps. Chris
... View more
07-06-2018
07:51 AM
|
0
|
0
|
1978
|
POST
|
Hello! Sorry about the late response, I was on a trip! I have reached out to NOAA about this issue as I am experiencing similar behavior with the layer. It seems that there is a defect with time-related layers that is present on the version of ArcGIS Server they are using. Here is their response: Hi Chris,
The issue you're experiencing is due to a bug with ArcGIS Server 10.5.
The map service is still time enabled - it will respond properly to time-enabled map requests - however the "Time Extent" metadata is not being exposed properly by ArcGIS Server. This causes any clients which rely on this metadata (e.g. ArcGIS Online maps) to mistakenly assume the service is not time-enabled.
We have logged this as a bug with the software vendor (ESRI) and are presently working with them to identify a solution, however it will likely be several weeks before they are able to deliver a patch for the issue.
We apologize for the inconvenience. If you can provide any more detail about your workflow, we may be able to identify a temporary workaround, but I can't guarantee anything right now.
If you have any other questions, please let us know.
Thanks,
Jason
--
Jason Greenlaw
Software Developer, ERT, Inc.
NOAA/NOS/OCS/CSDL
https://nowcoast.noaa.gov
Jason.Greenlaw@noaa.gov
I wish that I had more, but I hope this sheds some light on the issue. Thank you, Chris
... View more
06-11-2018
07:13 AM
|
1
|
1
|
3245
|
POST
|
Hi all! I used the sample that Atma Mani provided and created a small script to delete features from a Hosted Feature Service in AGOL that has multiple sub-layers. import os
import json
import arcgis
from arcgis.gis import GIS
import arcgis.features
layerName = 'title:Your Layer Name'
maxLayerAmount = 10 # number of sublayers
agolURL = "https://<your org>.maps.arcgis.com"
agolUN = "<Your UserName>"
agolPass = "<Your Password>"
# connect to your GIS
gis = GIS(agolURL, agolUN, agolPass)
layerCount = -1
while (layerCount < maxLayerAmount):
layerCount += 1
feature_layer_item = gis.content.search(layerName, item_type = 'Feature Service') [0]
flayers = feature_layer_item.layers
flayer = flayers[layerCount]
print("Layer ID: " + str(layerCount) + " Layer Name: " + flayer.properties.name)
flayer.delete_features(where="objectid > 0") I also added some logging to display the name of the layers as it loops through them. The logging looks something like this: Layer ID: 0 Layer Name: Point Layer
Layer ID: 1 Layer Name: Line Layer
Layer ID: 2 Layer Name: Polygon Layer I am still new to Python, so if there are any suggestions/comments, please let me know! Hope this helps! Chris
... View more
05-09-2018
12:21 PM
|
0
|
2
|
8777
|
POST
|
Hello all, I was setting up the DataStore (version 10.6.0) with a computer that had a touch screen monitor. I was experiencing the same issue where the DataStore configuration wizard would not display on the web page (the web page was blank). I called Esri Support and found out that there is a bug with running the DataStore Configuration Wizard on computers with touch Screen Monitors. Even though I was using a second monitor (not a touch screen), the fact that my main monitor was a touch screen was enough to cause the wizard to not display. For now, the workaround is to load the wizard's URL in another PC that does not have a touch screen. (or disconnect the monitor that is a touch screen). Esri Support let me know that they are planning to fix the bug in 10.6.1. Link to Bug: BUG-000110861: After installing ArcGIS Data Store 10.6 on a touchsc.. I hope this helps! Chris
... View more
04-18-2018
02:47 PM
|
0
|
0
|
2385
|
POST
|
I have found this when investigating Google Maps' TOS. I am not sure if it applies the same way to mobile app usage. TOS Section (10.4e): No use of Content with a non-Google map. You must not use the Content in a Maps API Implementation that contains a non-Google map. Link: Google Maps/Google Earth APIs Terms of Service | Google Maps APIs | Google Developers Hopefully Esri can work something out with Google. Thanks, Chris
... View more
02-07-2018
07:20 AM
|
0
|
0
|
874
|
DOC
|
William, Thanks for the edits and feedback! I made a few edits: 1. The widget panel would still open to the default size witch is not great for viewing the nws.gov site. I modified the js file to automatically resize the widget to a better size. onOpen: function () {
//Resize the Panel when opened. By: Robert Scheitlin
//GeoNet post: https://geonet.esri.com/thread/181865-how-to-change-wab-widget-window-size
var panel = this.getPanel();
panel.position.width = 600;
panel.setPosition(panel.position);
panel.panelManager.normalizePanel(panel);
}, 2. I added a command to remove the weather graphic from the map when the widget is closed. onClose: function () {
this.mapPinsGraphicsLayer.remove(graphic); //new addition
// this.map.graphics.remove(graphic); // old version
var thePanel = this.getPanel();
console.log(thePanel);
} If you want, I can post your modified version of the widget as an update to the original (version 1.2) and credit you for the update, or you can maintain this separate widget and I can provide a link to it in the description for the weather widget. Let me know. Thanks again! Chris
... View more
01-23-2018
12:24 PM
|
0
|
0
|
1392
|
DOC
|
Daniel, That is a good idea. I will look at adding something like that in the next version. Thanks for the feedback! Chris
... View more
01-19-2018
10:42 AM
|
0
|
0
|
3240
|
POST
|
Are you using layers from ArcGIS Online in addition to your locally hosted map services? If you are using layers hosted on ArcGIS Online, are those secured?
... View more
09-15-2017
06:33 PM
|
0
|
1
|
372
|
DOC
|
The purpose of this widget is to provide the user with access to local weather information and forecasts. The widget accomplishes this by accessing the user's location, allowing the user to manually enter Lat/Long coordinates, and by loading a forecast based on where on the map was clicked. It then loads the weather forecast (from the NWS) based on that location via an IFrame. ================================================================================================================================= What's new in version 1.2: A big Thank You to William Pelchat for his work on adding the new functionality! In this version, users can now manually enter Latitude and Longitude Coordinates to to load a new forecast from the NWS. Users can also click anywhere on the map (in the US) and get a forecast for that location. The symbol on the map has been updated, and now works in WAB DE. ================================================================================================================================= This widget was created and updated with WAB DE 2.5. I have also tested it in WAB DE v2.16. Currently, there are some styling issues with the Dashboard theme. I will work on these issues and hopefully have them resolved in the next widget version. Here is an example image: Thank you, Chris NOTE: Link to William Pelchat's original edits: ModifiedWeather.zip
... View more
09-14-2017
03:04 PM
|
2
|
5
|
7753
|
POST
|
Karen, There has been an update with the layer. In one of the previous updates to ArcGIS Online, Esri updated the Instagram Layer to require the user to sign-in to an existing Instagram Account. (Similar to the Twitter layer). This only works, however, on the latest version of the Public Information App Template (currently used in ArcGIS Online). Earlier versions will attempt to log into Instagram via an API key, which (for Esri use) was disabled by Instagram. For those looking to use the PIM app template by downloading it from the Esri GitHub page, it appears that you still must register the app with Instagram and provide a ClientID (from Instagram) and a Sign In URL (also from Instagram). I hope this helps, Chris
... View more
09-06-2017
02:45 AM
|
1
|
1
|
1416
|
POST
|
Hello all, I fixed the issue, but I'm sure that it is not the best way to do it. Here is what I came up with. Please let me know if there is a better way to go about this! Thank you! postCreate: function () {
//################# My Edits###############//
var r = /\d+/g;
var id = this.id;
var matchValue = id.match(r);
console.log(matchValue);
if (matchValue[0] != 0) {
domConstruct.destroy("jimu_dijit_SEFilterEditor_" + --matchValue)
}
//################ End Edits ##############//
this._createFilterTool();
}, This is located in the postCreate function in the "SEFilterEditor" js file. Thanks! Chris
... View more
06-22-2017
03:25 PM
|
0
|
0
|
580
|
POST
|
Hello all, I have noticed that the Smart Editor Widget in WAB DE 2.1 loads the search template bar twice when a layer is chosen, a feature is added, and then the Smart Editor Widget is closed and reopened. Example: Open the widget and select a layer to edit: The layer selected is "Polygon" Add a feature Select "Save" Smart Editor template search behaves normal Close the Smart Editor Widget and then reopen it. Result: If anyone has come across this before, please let me know! NOTE: To fix the error, the WAB app must be refreshed. Thanks! Chris
... View more
06-22-2017
01:21 PM
|
0
|
1
|
1454
|
POST
|
Malla, Take a look at the Graphics Layer Link in the JS API. GraphicsLayer | API Reference | ArcGIS API for JavaScript 3.20 There is a property in it that expects an array of graphics. They make up the layer. Here is the link to the JS API for an individual graphic. Graphic | API Reference | ArcGIS API for JavaScript 3.20 Here is an example of adding an individual graphic to a map using JSON, notice the "MyPoint" variable is raw JSON, I think this is what rscheitlin, is looking for when he asks what your JSON output is. require([
"esri/graphic"
], function(Graphic) {
var myPoint = {"geometry":{"x":-104.4140625,"y":69.2578125,
"spatialReference":{"wkid":4326}},"attributes":{"XCoord":-104.4140625,
"YCoord":69.2578125,"Plant":"Mesa Mint"},"symbol":{"color":[255,0,0,128],
"size":12,"angle":0,"xoffset":0,"yoffset":0,"type":"esriSMS",
"style":"esriSMSSquare","outline":{"color":[0,0,0,255],"width":1,
"type":"esriSLS","style":"esriSLSSolid"}},
"infoTemplate":{"title":"Vernal Pool Locations","content":"Latitude: ${YCoord} <br/> Longitude: ${XCoord} <br/> Plant Name:${Plant}"}};
var gra = new Graphic(myPoint);
...
}); The JSON above includes the point's geometry, Spatial Reference, attributes, symbology, and InfoTemoplate (Popup) information. NOTE: I used the "Point" example above, but there are also examples for lines and Polygons. I hope this helps! Chris
... View more
06-20-2017
10:54 AM
|
1
|
0
|
565
|
Title | Kudos | Posted |
---|---|---|
1 | 06-10-2016 07:23 AM | |
1 | 05-24-2021 02:27 PM | |
1 | 11-02-2016 02:19 PM | |
1 | 05-18-2016 08:47 AM | |
1 | 01-04-2017 06:06 AM |
Online Status |
Offline
|
Date Last Visited |
07-31-2024
12:30 PM
|