Heres some code I wrote in Ruby on Rails for a dynamic map:<br> def dynamic_map<br> # ====================<br> # Grab values from the form<br> # ====================<br> @minx_d = params[:minx_d].to_f # default extent values
<br> @miny_d = params[:miny_d].to_f<br> @maxx_d = params[:maxx_d].to_f<br> @maxy_d = params[:maxy_d].to_f<br> @minx_img = params[:minx_img].to_f # image coordinate values<br> @miny_img = params[:miny_img].to_f
<br> @maxx_img = params[:maxx_img].to_f<br> @maxy_img = params[:maxy_img].to_f<br> @pin = params[:pin].to_s # parcel identification number<br> @minx = params[:minx].to_f # current extent values<br> @miny = params[:miny].to_f
<br> @maxx = params[:maxx].to_f<br> @maxy = params[:maxy].to_f<br> @zoomfactor = params[:zoomfactor].to_i # -2 is zoomout, -1 or 1 is recenter, 2 is zoomin (Integer value).<br> @tool = params[:tool].to_s # This should match the 'getToolbox()' JavaScript function.
<br> <br> # ==============<br> # Initialize MapObj<br> # ==============<br> @map = MapObj.new session['mapfile']<br> @map.setExtent @minx, @miny, @maxx, @maxy<br> <br> # ====================
<br> # Paint the selection yellow.<br> # ====================<br> layer = @map.getLayerByName 'parcel_poly'<br> layer.classitem = 'PIN'<br> <br> class_poly_hilite = layer.getClass 0<br>
layer.insertClass class_poly_hilite<br> <br> class_poly_hilite.name = 'poly_hilite'<br> class_poly_hilite.setExpression @pin.strip<br> <br> class_poly_hilite_style = class_poly_hilite.getStyle 0<br>
class_poly_hilite_style.color<div id="1f0w" class="ArwC7c ckChnd">.setRGB 250, 250, 125<br> <br> # =============<br> # Add a push-pin.<br> # =============<br> layer_pt = @map.getLayerByName 'parcel_point'
<br> layer_pt.classitem = 'pin'
<br> <br> class_pt_hilite = layer_pt.getClass 0<br> layer_pt.insertClass class_pt_hilite<br> <br> class_pt_hilite.name = 'pt_hilite'<br> class_pt_hilite.setExpression @pin.strip<br> <br> class_pt_hilite_style = class_pt_hilite.getStyle 0
<br> class_pt_hilite_style.size = 32<br> class_pt_hilite_style.setSymbolByName @map, 'pushpin'<br> <br> # ===================================<br> # Apply the zoom (aka change the extent value).<br>
# ===================================
<br> if @minx_img != @maxx_img && @miny_img != @maxy_img<br> apply_box @map, @minx_img, @miny_img, @maxx_img, @maxy_img<br> elsif @tool == 'fullview'<br> @map.setExtent @minx_d, @miny_d, @maxx_d, @maxy_d
<br> else<br> apply_zoom @map, @zoomfactor, @minx_img, @miny_img<br> end<br><br> # Set the new extent values to be sent back to the form.<br> @minx = @map.extent.minx.to_f<br> @miny = @map.extent.miny.to_f
<br> @maxx = @map.extent.maxx.to_f<br> @maxy = @map.extent.maxy.to_f<br> <br> render :partial => 'map_image'<br> end<br><br>Here's a snippet from my mapfile:<br> LAYER #-- Parcels Polygon Layer
<br> NAME parcel_poly<br> DATA parcelpydoug04<br> MAXSCALE 72000<br> STATUS DEFAULT<br> TYPE POLYGON<br> TRANSPARENCY 50<br> CLASS<br> NAME "Parcels"<br> COLOR -1 -1 -1<br> OVERLAYOUTLINECOLOR 250 0 0
<br> OVERLAYSYMBOL 'circle'<br> OVERLAYSIZE 2<br> END<br> END #-- Parcels Polygon Layer<br><br> LAYER #-- Parcels Point Layer<br> NAME parcel_point<br><br> CONNECTIONTYPE postgis
<br> CONNECTION "user=<username_goes_here> dbname=experiments host=localhost port=5432 password=<password_goes_here>"
<br> DATA "wkb_geometry from mn_douglas_parcelpoints"<br><br> MAXSCALE 72000<br> STATUS DEFAULT<br> TYPE POINT<br> #-- TOLERANCEUNITS miles<br> #-- TOLERANCE 10<br> TRANSPARENCY 50<br> CLASS
<br> NAME "Parcel Point"<br> COLOR 0 250 0<br> SYMBOL 'circle'<br> SIZE 10<br> END<br> END #-- Parcels Point Layer<br><br>In
version 4, the parcel lines and points are drawn. The code written
above highlights the selected parcel and changes the point graphic to a
push-pin.
<br>In version 5, the parcel lines and points are not drawn. Only the
highlighted parcel is drawn. Why? How do I write my code so that it
displays the defaults from the mapfile as well as the newly defined
class? I'm stumped.
<br><br>Any comments or suggestions appreciated.<br>~Brant</div>