[OpenLayers-Users] custom control.button problems
Heidt, Christopher M.
CHRISTOPHER.M.HEIDT at saic.com
Mon Jan 5 12:13:04 EST 2009
And if u need to pass a variable
var onTrigger = function(variableName) {
alert(variableName);
};
var btn = new OpenLayers.Control.Button({
trigger: function(variableName){
onTrigger(variableName);
}
});
The basic principle here is that you need to store a function in
trigger.
Your code was tring to store the output of a function in trigger.
-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of Eric Lemoine
Sent: Monday, January 05, 2009 12:07 PM
To: David Hollema; users at openlayers.org
Subject: Re: [OpenLayers-Users] custom control.button problems
Hi
You don't pass a function in the options but the return code of a
function.
Try this:
var onTrigger = function() {
alert("yo");
};
var btn = new OpenLayers.Control.Button({
trigger: onTrigger
});
Cheers,
Eric
2009/1/5, David Hollema <dhollema at unitedpower.com>:
> 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.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list