Note that there are some explanatory texts on larger screens.

plurals
  1. POControl activates before button click
    text
    copied!<p>I have a custom toolbar that fires events on html button click, there is a problem with one where it's activated on init instead of after button click.. it seems to trigger the function on init. The controls toggle correctly but it seems to be activated by default or within init.</p> <p>Here is the code:</p> <pre><code>/* other Controls */ polygon: new OpenLayers.Control.Measure( OpenLayers.Handler.Polygon, { persist: true, immediate: true, handlerOptions: { layerOptions: { renderers: renderer, styleMap: styleMap } } } ), choose: new OpenLayers.Control.Button({ /** **/ activateControl: false, /** Problem here **/ trigger: tochiSentaku() /** **/ }) }; var control; for(var key in allControls) { control = allControls[key]; control.events.on({ "measure": handleMeasurements, "measurepartial": handleMeasurements, "button": tochiSentaku }); map.addControl(control); } function toggleControl(element){ for(key in allControls){ var control = allControls[key]; if(control.active){ control.deactivate(); } if(element.value == key &amp;&amp; element.click){ control.activate(); vlayer.removeAllFeatures(); var mybutton = document.getElementById('output'); var xyz = ""; mybutton.innerHTML = xyz; } else{ control.deactivate(); } } } </code></pre> <p>tochiSentaku Function</p> <pre><code>function tochiSentaku(evt){ var element = document.getElementById("attribute"); map.events.register('click', map, function(e){ vlayer.destroyFeatures(vlayer,features); var coord = $(".olControlMousePosition").text(); $("#attribute").html('&lt;center&gt;&lt;img src="images/loading.gif" alt="Now Loading..." /&gt;&lt;/center&gt;'); $.getJSON("scripts/tochi_sentaku.php",{coord:coord}, function(data){ $("#attribute").html("&lt;button id=\"attribute_map\" onclick=\"" + data.the_geom + "\"&gt;地図&lt;/button&gt;&lt;table id='attribute_tbl'&gt;&lt;tr&gt;&lt;th&gt;項目名&lt;/th&gt;&lt;th&gt;値&lt;/th&gt;&lt;/tr&gt;&lt;/table&gt;"); for(var key in data){ if(key != "the_geom"){ $("#attribute_tbl").append("&lt;tr&gt;&lt;td&gt;" + key + "&lt;/td&gt;&lt;td&gt;" + data[key] + "&lt;/td&gt;&lt;/tr&gt;"); } } $("#attribute_map").click(); }); }); } </code></pre> <p>If anyone can give me some advice would greatly appreciate it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload