Openlayers change WMS call URL -



Openlayers change WMS call URL -

i'm relatively inexperienced openlayers, , i've been trying figure out while now. i've created layer on map wms call. have url set when click radio button, runs function, , inserts part of url link proper file on server. it's improve explain code...

var layer_type = "tavg_sddiff"; var layer_name = "tavg_sd_diff"; function layer_names(id) { layer_type = openlayers.util.getelement(id).id; } tavg = new openlayers.layer.wms("tavg", "http://convection.meas.ncsu.edu:8080/thredds/wms/sco/synthesis/eval_wicci_" + layer_type + "_50km.nc?", {layers: layer_name, version:'1.1.1', crs:'crs:84', "transparent":'true', "styles":'boxfill/shrmc-mxhgt', "colorscalerange":'-2.1,2.1', "numcolorbands":'42', "abovemaxcolor":'extend', "belowmincolor":'extend', time:"2001-01-01t00:00:00"}, {isbaselayer:false, setvisibility: true, transparent:true,displayinlayerswitcher:true}); tavg.url = "http://convection.meas.ncsu.edu:8080/thredds/wms/sco/synthesis/eval_wicci_" + layer_type + "_50km.nc?";

so layer_type , layer_name alter depending on radio button selected. know variables change, becasue have checked alert() in function.

also have function redraws layer new info can displayed.

function deletelayer() { tavg.redraw(); alert(tavg.url); }

here problem, when insert alert in sec function, see url not alter in map variable, hence it's not changing on map when select different buttons , redraw command thing. possible update map without having add together separate map variable layers each file?

to alter part of wms query string in openlayers, there mergenewparams function, update , re-request of tiles, see line 222, http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/openlayers/layer/wms.js. clear, works on query string of request.

in case, seems have different layers , layer types part of url. going have phone call map.removelayer(tavg), create new wms request url , explicitly re-add wms map.addlayer(tavg) again.

in general, if have resource @ scale, url suggests do, ...thredds/wms/sco/synthesis/eval_wicci_" + layer_type + "_50km.nc?", different thematic views, might improve off handling using layers , styles parameters of wms, 1 url, otherwise might end hundreds of different urls show different views of same tile, quite messy server perspective. also, note fact openlayers has mergenewparams function, expected way handle sort of situation.

edit: after farther dig through source code, might able want explicitly setting url, seturl function next phone call redraw. both of these functions in openlayers.layer.httprequest openlayers.layer.wms inherits of methods via openlayers.layer.grid.

wms.seturl(newurl); wms.redraw();

i have no easy means of testing this, allow me know if have issues.

openlayers wms

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -