[OpenLayers-Users] custom control.button problems

David Hollema dhollema at UnitedPower.com
Mon Jan 5 11:50:47 EST 2009


Couple question as an openlayers newbie.

* I can't get custom control.buttons to fire.  What am I doing wrong?  I
tried in IE7 and FF and neither work properly.
* When I first open the web page, the functions which are assigned to
the trigger events of my custom control buttons are fired.  What's going
on here?  This function below gets called during the body onload of the
html.  I don't see why it's calling the trigger events are called.

		function init(){
	
				/*var options = {
                    controls: [new OpenLayers.Control.MouseDefaults()],
units: 'ft'
                };*/
				
				var options = {
                    units: 'ft'
					//projection: "EPSG:4326"
                };
				
				map = new OpenLayers.Map('map' ,
options);
				
	
document.getElementById('IDimgFolder').value = baseURL;
				setImgArray();
				/*var wms = new OpenLayers.Layer.WMS(
                    "OpenLayers WMS",
                    "http://labs.metacarta.com/wms/vmap0?",
                    {layers: 'basic'}
                );*/
                //map.addLayer(wms);

				//debugger;
				pointLayer = new
OpenLayers.Layer.Vector("Target Picks", {geometryType:
OpenLayers.Geometry.Point});
				map.addLayer(pointLayer);
				
				//debugger;
				//OpenLayers.ProxyHost="/proxy/?url=";
				//var newl = new OpenLayers.Layer.Text(
"text", {location: "test.txt"} );
				//var newl = new OpenLayers.Layer.Text(
"text", {location: "http://openlayers.org/dev/examples/textfile.txt"} );
				//var newl = new OpenLayers.Layer.Text(
"text", {location: "c://temp//test.txt"} );
				//map.addLayer(newl);
				
				//var new2 = new OpenLayers.Layer.GML(
"textGML", "http://upigis/joint use/test.txt",{format:
OpenLayers.Format.Text});
				//map.addLayer(new2);

                var new3 = new OpenLayers.Layer.GML( "Target Picks GML",
"http://upigis/joint use/point.xml");
				map.addLayer(new3);
				//map.setLayerIndex(new3, 0);
				
				map.setCenter(0,0);
				map.addControl(new
OpenLayers.Control.MousePosition({div:
document.getElementById("mouseposition"), 
				prefix: "mouse pos:  (", suffix: ")"}));
				map.addControl(new
OpenLayers.Control.PanZoom());
				map.addControl(new
OpenLayers.Control.LayerSwitcher());
				
				var overview = new
OpenLayers.Control.OverviewMap();			
				map.addControl(overview);
				
				var panCustom = new
OpenLayers.Control.MouseDefaults(
                    {title:'You can use the default mouse
configuration'});
					
				var zb = new OpenLayers.Control.ZoomBox(
                {title:"Zoom box: Selecting it you can zoom on an area
by clicking and dragging."});
							
				var drawPtControl = new
OpenLayers.Control.DrawFeature(pointLayer,
                                OpenLayers.Handler.Point, {title:'Pick
target on photo'});	
				
				var dragPtControl = new
OpenLayers.Control.DragFeature(pointLayer, {title:'Move target pick'});
				//map.addControl(dragPtControl);
				
				var history = new
OpenLayers.Control.NavigationHistory();				
				map.addControl(history);
				
				var clearPicksBtn = new
OpenLayers.Control.Button({trigger: clearPicks(pointLayer),
displayClass: "clearPicksBtn",
				title:'Clear all picks'});
				
				var prevPhotoBtn = new
OpenLayers.Control.Button({trigger: f_slideshow(-1), displayClass:
"prevPhotoBtn",
				title:'Previous photo'});
				
				var nextPhotoBtn = new
OpenLayers.Control.Button({trigger: f_slideshow(1), displayClass:
"nextPhotoBtn",
				title:'Next photo'});
				
				//var panel = new
OpenLayers.Control.Panel({div: document.getElementById("panel")});
				var panel2 = new
OpenLayers.Control.Panel({div: document.getElementById("panel2"),
defaultControl: panCustom});
				
				
				panel2.addControls([panCustom, zb,
history.next, history.previous, drawPtControl, 
				dragPtControl, clearPicksBtn,
prevPhotoBtn, nextPhotoBtn]);
				map.addControl(panel2);
            }



David A. Hollema
GIS Analyst
 
United Power, Inc.



More information about the Users mailing list