function createWmsLayer() { var layer = new esri.layers.WMSLayer("http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer"); layer.setVisibleLayers([2]); layer.setImageFormat("png"); return layer; } map.addLayer(createWmsLayer()); map.addLayer(createWmsLayer());
http://localhost:55240/Proxy.ashx?http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetCapabilities http://localhost:55240/Proxy.ashx?http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetCapabilities http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=TRUE&STYLES=&VERSION=1.3.0&LAYERS=2&WIDTH=996&HEIGHT=630&CRS=EPSG:4326&BBOX=18.1801624186747,-125.192865,55.5544955813253,-66.105824
The documentation for refresh() states, "Refreshes the map by making a new request to the server. In order to refresh the layer in this manner, setDisableClientCaching must be true. This ensures that map images are not cached on the client. (As of v1.2)" but setDisableClientCaching is defined for ArcGISDynamicMapServiceLayer and not DynamicMapServiceLayer. Calling refresh on a WMSLayer instance has no affect.
i was wondering if it is detecting a duplicate.
layer = new esri.layers.WMSLayer("http://sampleserver1c.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer", { visibleLayers: ['1', '2'] }); aspect.after ( layer, "onLoad", function () { var getImageUrl, tick; tick = 0; getImageUrl = layer.getImageUrl; layer.getImageUrl = function ( extent, width, height, callback ) { var result = getImageUrl.call ( layer, extent, width, height, function (url) { callback.call ( layer, url + "&_c=" + tick++ ); } ); return result; }; setInterval ( function () { layer.refresh (); }, 5000 ); }); map.addLayer(layer);
new Date().getTime()
new Date().valueOf()
function extendLayer(layer) { var getImageUrl; getImageUrl = layer.getImageUrl; layer.setDisableClientCaching = layer.setDisableClientCaching || function (disable) { layer.disableClientCaching = disable; if (disable) { layer.getImageUrl = function (extent, width, height, callback) { var result = getImageUrl.call(layer, extent, width, height, function (url) { callback.call ( layer, url + "&_c=" + ( new Date () ).getTime () ); }); return result; }; } else { layer.getImageUrl = getImageUrl; } }; return layer; }
Very useful! It works! I used your suggestion to refresh a service with both a wms from geoserver and a layer from arcgis server and everything is fine.
Thanks!
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.