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
|
109
|
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
|
114
|
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
|
116
|
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
|
374
|
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
|
1099
|
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
|
306
|
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
|
88
|
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
|
160
|
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
|
413
|
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
|
10
|
Online Status |
Offline
|
Date Last Visited |
01-15-2021
03:03 PM
|