POST
|
I have a series of layers that are loaded via CSV on my local server. The code below is repeated for each layer. However, for whatever the reason the layer graphics get hung up on the screen and cannot be cleared until the whole page is refreshed. I have tried building a function to clear or remove the layers before the refresh but that does not seem to work either. It seems to be tied to the CSV data being updated, which is done via a local CRON every five minutes. For testing, I have opened the CSV and changed on points' value, and it seems to hang for sure at that point. Thoughts? function csv60minfunc () { csv60min = new CSVLayer("symGSPHydroViewer/data/60query.csv",{id:"csv60min"}); csv60min.refreshInterval = 0.1; csv60min.on("update-end", function(results){ csv60mintextLayer = new GraphicsLayer(); arrayUtils.forEach(results.target.graphics, function(feature, index){ var lid = feature.attributes.lid; var name = feature.attributes.name; var value = feature.attributes.value; var ffg = feature.attributes.ffg; var ratio = feature.attributes.ratio; var validtime = feature.attributes.obstime; var attr = {"Location ID":lid,"Location Name":name,"Obs Value":value,"FFG":ffg,"Ratio of FFG":ratio,"Obs Valid Time":validtime}; var geom = feature.geometry; var displayText = feature.attributes.value; var font = new Font("12pt",Font.STYLE_NORMAL, Font.VARIANT_NORMAL,Font.WEIGHT_BOLD,"Helvetica"); var textSymbol = new TextSymbol(displayText,font,new Color("#FF0000")); csv60mintextLayer.add(new Graphic(geom, textSymbol, attr));}); var infoTemplate = new InfoTemplate("Attributes", "${*}"); csv60mintextLayer.setInfoTemplate(infoTemplate); map.addLayer(csv60mintextLayer); csv60mintextLayer.hide(); }); var blank = new Color([0, 0, 0, 0]); // hex is #ff4500 var marker = new SimpleMarkerSymbol("solid", 0, null, blank); var renderer = new SimpleRenderer(marker); csv60min.setRenderer(renderer); map.addLayer(csv60min); csv60min.hide(); }
... View more
07-10-2014
07:01 AM
|
0
|
0
|
1748
|
POST
|
Specifically with CSV Layers, how does the API handle refreshing CSV Layers when the map is open? I have been trying to make this work for sometime now and I cant pin down why I have been unsuccessful. I have a series of CSV Layers that I create upon initialization of the map. Those layers obviously reference CSV files on my local server. Those CSV files update every five minutes with new data. Thus, I need the map to update all the CSV layers (visible or not) at that time. I have tried using the refreshInterval option, but with no luck. Sample code is below. //Add Observed Precip CSV Layers function csv30min () { csv30min = new CSVLayer("symGSPHydroViewer/data/30query.csv",{id:"csv30min"}); csv30min.refreshInterval = 0.1; csv30min.on("update-end", function(results){ csv30mintextLayer = new GraphicsLayer(); arrayUtils.forEach(results.target.graphics, function(feature, index){ var lid = feature.attributes.lid; var name = feature.attributes.name; var value = feature.attributes.value; var ffg = feature.attributes.ffg; var ratio = feature.attributes.ratio; var validtime = feature.attributes.obstime; var attr = {"Location ID":lid,"Location Name":name,"Obs Value":value,"FFG":ffg,"Ratio of FFG":ratio,"Obs Valid Time":validtime}; var geom = feature.geometry; var displayText = feature.attributes.value; var font = new Font("12pt",Font.STYLE_NORMAL, Font.VARIANT_NORMAL,Font.WEIGHT_BOLD,"Helvetica"); var textSymbol = new TextSymbol(displayText,font,new Color("#FF0000")); csv30mintextLayer.add(new Graphic(geom, textSymbol, attr));}); var infoTemplate = new InfoTemplate("Attributes", "${*}"); csv30mintextLayer.setInfoTemplate(infoTemplate); map.addLayer(csv30mintextLayer); csv30mintextLayer.hide(); }); var blank = new Color([0, 0, 0, 0]); // hex is #ff4500 var marker = new SimpleMarkerSymbol("solid", 0, null, blank); var renderer = new SimpleRenderer(marker); csv30min.setRenderer(renderer); map.addLayer(csv30min); csv30min.hide(); }
... View more
07-09-2014
06:53 AM
|
0
|
0
|
1785
|
POST
|
Well I tried that and it seems to still be only updating when I pan/zoom. I copied in exactly what you have in the post above. All I did was change the interval to 1 minute. I sat and watched for ten minutes with no update. As soon as I touched the map and panned just a bit, it updated. wmsRadarLayer.refreshInterval = .05;
... View more
07-08-2014
10:59 AM
|
0
|
0
|
701
|
POST
|
Thanks for the help John. However, the WMS Layer still only updates when I physically pan/zoom the map. Here is the modification I made to the WMSLayer call. var layers = new WMSLayerInfo({}); var resourceInfo = {extent: new Extent(-126.40869140625, 31.025390625, -109.66552734375, 41.5283203125, {wkid: 4326}),layerInfos: [layers]}; var wmsRadarLayer = new WMSLayer('http://nowcoast.noaa.gov:80/wms/com.esri.wms.Esrimap/obs?', {resourceInfo: resourceInfo,visibleLayers: ['RAS_RIDGE_NEXRAD'],"visible":false,"setDisableClientCaching":true,"refreshInterval":1.0,opacity:0.9}); wmsRadarLayer.version = "1.1.1";
... View more
07-08-2014
09:58 AM
|
0
|
2
|
701
|
POST
|
All, I have a series of WMS layers that I'm pulling in from NOAA's NowCoast. All is well except when trying to refresh the layers. I have the page setup to auto refresh, and also to refresh using an onClick button. When I click the button (after waiting sufficient time for the image to be updated on the parent server), nothing happens. However, as soon as I pan or zoom the map, it refreshes. So did some searching and found an old thread that suggested including map.setExtent(map.extent) in the refresh function. So I did this, which is what actually makes the map refresh on pan/zoom I believe, without that, it wouldn't even refresh on pan/zoom. Thus, I am still not getting what I want. Can anyone help me out?
function RefreshWMSLayers(){ wmsRadarLayer.refresh(); wmsWarnLayer.refresh(); wmsGOESVISLayer.refresh(); wmsGOESIRLayer.refresh(); wmsOBSLayer.refresh(); wmsTempLayer.refresh(); wmsSSTLayer.refresh(); } function AutoRefreshMap(){ dts = getDateTime(); console.log("Auto Refreshing at " + dts); document.getElementById('DTS').textContent = dts; RefreshWMSLayers(); map.setExtent(map.extent); } function RefreshMap(){ dts = getDateTime(); console.log("On Demand Refreshing at " + dts); document.getElementById('DTS').textContent = dts; RefreshWMSLayers(); map.setExtent(map.extent); }
... View more
07-08-2014
07:40 AM
|
0
|
6
|
3260
|
POST
|
I'm trying to incorporate the following link, into the following code and cant figure it out. Have made various attempts but am unsure of where exactly to place the link. Info Layer link: nowCOAST Layer Info Retrieval
var layers = new WMSLayerInfo({}); var resourceInfo = {extent: new Extent(-126.40869140625, 31.025390625, -109.66552734375, 41.5283203125, {wkid: 4326}),layerInfos: [layers]}; var wmsWarnLayer = new WMSLayer('http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/wwa?', {resourceInfo: resourceInfo,visibleLayers: ['WARN_SHORT_TOR','WARN_SHORT_SVR','WARN_SHORT_FLW','WARN_SHORT_FFW'],"visible":false, opacity:0.7}); wmsWarnLayer.version = "1.1.1"; map.addLayers([wmsWarnLayer]);
... View more
07-08-2014
05:50 AM
|
0
|
0
|
1714
|
POST
|
Charles, No probs, glad you have got it working, please don't forget to mark the post as answered by checking the tick box on my post and hitting the up arrow, Regards Anthony Done! One more quick question however, how would I incorporate the following layerinfo link into the WMSLayerInfos? Cant seem to figure this out. Thanks. link: http://nowcoast.noaa.gov/LayerInfo?layer=RAS_RIDGE_NEXRAD&data=timestamp
var layers = new WMSLayerInfo({});
var resourceInfo = {extent: new Extent(-126.40869140625, 31.025390625, -109.66552734375, 41.5283203125, {wkid: 4326}),layerInfos: [layers]};
var wmsRadarLayer = new WMSLayer('http://nowcoast.noaa.gov:80/wms/com.esri.wms.Esrimap/obs?', {resourceInfo: resourceInfo,visibleLayers: ['RAS_RIDGE_NEXRAD'],"visible":false, opacity:0.7});
wmsRadarLayer.version = "1.1.1";
... View more
07-01-2014
06:30 AM
|
0
|
0
|
775
|
POST
|
Anthony, Works like a charm! Thanks a million! Charles Charles, I think you need to actually specify your layer names in the visible layers (1 & 2 do not exist). Get your layer names from the capabilities file http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?service=wms&version=1.1.1&request=GetCapabilities The following code works in the sandbox (http://developers.arcgis.com/javascript/sandbox/sandbox.html)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Map with WMS</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css">
<style>
html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; }
</style>
<script src="http://js.arcgis.com/3.9/"></script>
<script>
var map;
require([
'esri/map', 'esri/layers/WMSLayer', 'esri/layers/WMSLayerInfo', 'esri/geometry/Extent',
'dojo/_base/array', 'dojo/dom', 'dojo/dom-construct', 'dojo/parser',
'dijit/layout/BorderContainer', 'dijit/layout/ContentPane', 'dojo/domReady!'
],
function(Map, WMSLayer, WMSLayerInfo, Extent, array, dom, domConst, parser) {
parser.parse();
map = new Map('map', {
basemap: 'streets',
center: [-96, 37],
zoom: 4
});
var layer1 = new WMSLayerInfo({});
var resourceInfo = {
extent: new Extent(-126.40869140625, 31.025390625, -109.66552734375, 41.5283203125, {
wkid: 4326}),
layerInfos: [layer1]
};
var wmsLayer = new WMSLayer('http://nowcoast.noaa.gov:80/wms/com.esri.wms.Esrimap/obs?', {
resourceInfo: resourceInfo,
visibleLayers: ['world_countries_label','world_countries','RAS_RIDGE_NEXRAD','OBS_MET_TEMP'],
});
wmsLayer.version = "1.1.1";
map.addLayers([wmsLayer]);
});
</script>
</head>
<body class="claro">
<div id="map"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'center'"
style="overflow:hidden;">
</div>
</div>
</body>
</html>
Regards Anthony
... View more
06-30-2014
07:48 AM
|
0
|
0
|
775
|
POST
|
Just wanted to bump this back to the top as I'm still looking for a solution. Have tried to piece together some sample I found on the web with no luck.
... View more
06-30-2014
04:32 AM
|
0
|
0
|
363
|
POST
|
Any help that anyone could provide would be greatly appreciated. Thanks!
... View more
06-30-2014
04:29 AM
|
0
|
0
|
775
|
POST
|
Thanks Scott! Will see what I can do with this. Greatly appreciated. Are these actual CSVLayer() layers? If so, they should have a "visible" property: https://developers.arcgis.com/javascript/jsapi/csvlayer-amd.html#visible so reading yourCSVLayerName.visible should return true or false. Actually, other types of layers have the same "visible" property: https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#visible https://developers.arcgis.com/javascript/jsapi/arcgisdynamicmapservicelayer-amd.html#visible So you can just write some logic to check for that like: if (!yourCSVLayerName.visible) {
yourCSVLayerName.show();
}
Or you could do something like this:
function getLayerProperties() {
for(var j = 0; j < map.layerIds.length; j++) {
var layer = map.getLayer(map.layerIds );
if (!layer.visible) { //if layer is not visible
layer.show();
}
}
}
}
... View more
06-30-2014
04:19 AM
|
0
|
0
|
247
|
POST
|
All, Is there a built in method or function within the API that when executed will return an array of currently visible layers? I have some functions written to refresh my map at certain time intervals, and also on command via a evt button. I need to know which layers are currently visible before the refresh script runs so that I can turn them all back on. You might be asking, why do they go off? Well, they don't all go off, just certain csv layers. I have 5 csv layers that are each created with a separate function. Within the function, at the end is a .hide() command so that when the page is loaded the data is already created, but not visible. Then the layer of choice is just turned on with another evt button. However, if the user has one of these layers activated and the refresh function runs, which recreates the csv layers to populate new data (data is updated every five minutes), it will be invisible. Thus, the need to know ahead of time which are visible so I can loop through them at the end of the refresh function to .show() them again. Thanks!
... View more
06-26-2014
02:19 AM
|
0
|
2
|
546
|
POST
|
Any help that anyone could provide would be greatly appreciated. Thanks!
... View more
06-24-2014
07:29 PM
|
0
|
0
|
775
|
POST
|
All, Has anyone had any luck importing the NowCoast WMS layers into the API? I'm not exactly sure how I'm supposed to set it up. Do I use the "Get Capabilities" server, do I not? Anyone have any code snippets? Below is what I have, after trying to piece it together from the sample provided on the reference page. Went the resource info route since I don't have a proxy page. Thanks in advance! //Add Web Mapping Services (WMS) var layer1 = new WMSLayerInfo({name: '1',title: 'name1}); var layer2 = new WMSLayerInfo({name: '2',title: 'name2'}); var resourceInfo = {extent: new Extent(-126.40869140625, 31.025390625, -109.66552734375, 41.5283203125, {wkid: 4326}),layerInfos: [layer1, layer2]}; var wmsLayer = new WMSLayer('http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs', {resourceInfo: resourceInfo,visibleLayers: ['1', '2']}); map.addLayers([wmsLayer]);
... View more
06-23-2014
02:41 AM
|
0
|
6
|
2061
|
Title | Kudos | Posted |
---|---|---|
1 | 05-04-2012 06:30 PM | |
1 | 05-13-2012 06:45 AM | |
1 | 05-17-2014 01:34 PM | |
1 | 05-02-2015 03:51 AM | |
1 | 05-07-2015 03:54 AM |
Online Status |
Offline
|
Date Last Visited |
03-04-2022
02:18 PM
|