I'm using OpenLayers and I'm having a problem with select feature functionality:
When there is an EditingToolbar added to the map, the SelectFeature control isn't working properly. It doesn't select the feature, it can only highlight it.
I guess that's because the click of the DrawFeature Control and the SelectFeature Control interfere.
The only solution I managed to come up with is to deactivate the EditingToolbar.
This is the eaxmple that I use to find a solution to the problem. I simply add an EditingToolbar to the map from my console and try to debug from there:
http://openlayers.org/dev/examples/highlight-feature.html
How can I solve this problem without deactivating the EditingToolbar?
Thank you for your time and kind concern.
The way I figured out how to do it is to do:
editing_toolbar.controls[2].deactivate();
Now I can select the features that I need.
Of course, editing_toolbar is the reference to the EditingToolbar object and the control is chosen at random; in reality you need to check all controls and find the one that is active, and then deactivate it.
Related
I'm creating a mapbox plugin that should update when a layer is added or removed. There are events for style and source adding, but none for layer.
My current solution is to programatically fire custom events after adding or removing layers that are listened inside the plugin, but this of course happens outside the scope of the plugin and it's not an appropriate solution.
What would be the best approach to handle this?
Listen to the styledata events. It gets called any time a layer is added or removed. You might have to keep track of which layers were present beforehand to know if that change specifically has occurred.
I have a LeafletJS control that renders a button. I want the button, when clicked, to open a popup on its position. So far I've tried calling the .bindPopup method on the control itself, which WebStorm seems to approve of, but the browser tells me that this method doesn't exist. What would be the preferred way to accomplish this task?
Leaflet controls don't implement the .bindPopup function.
Instead, you might find some luck looking at how the layers control works, it collapses/expands based on mouse events. You could potentially do something similar with your control, and show/hide your popup based on the click event and toggling a display: none css property.
I am using Google Maps API to provide a form in a custom Map Overlay, similar to a native InfoWindow. I used an example by google to create a custom overlay, using their OverlayView Prototype.
Eventually this overlay doesn't have the same behaviour InfoWindow has regarding editing. Interacting with the window results in interaction with the map. One can neither select text in the window nor edit an input-field. Events are delegated to the map.
I already tried to play around with z-index, which won't work.
In their example you can't select text either - therefore you might have a look at their source.
It actually is a question of event propagation. Google provides another less obvious example which solves the problem:
http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/src/infobox.js
---> UPDATE 01/2015
Ian added another example that blocks propagation of all map events in comments.
So I have looked through most of the facebook questions here and it has absolutely confirmed my thoughts. Facebook development may be among some of the worst I've ever used. I'll avoid my rant for now, but as a note to where I'm coming from: tried php sdk, worked decently out of the box, found out I need to put the functionality on a pages tab, can't iframe on pages tab, have to use FBML (which they are retiring in two months, yet I can't start testing the iframe approach yet)
Anyway, I run into FBJS at this point. It works "good enough" for most things, but for some reason I can't get an event registered to an object (a select box in particular interest) by adding a listener (as per FBJS documentation). I am able to add it directly to the html object and have it work, but this is not desirable and I would really like to know what I consider the proper way to do it, which involves seperation of logic and display.
What I want to happen: click on the select box, make a selection, display the text of the selection in an empty div (later on adding Ajax but one step at a time here)
Code:
<script>
var obj = document.getElementById('select-id');
obj.addEventListener('onchange',my_func);
function my_func(evt){
var inner = document.getElementById('div-id');
inner.setTextValue('hey'); // for testing purposes
}
</script>
The above code doesn't do anything when I make a change to the select box. However, this behaves as planned:
<select name="find_state" id="find_state" onchange="my_func();">
I will be grudgingly using this method as I develop, but would really love to know what I might be doing wrong or if anyone else has this issue? And if anyone has any opinions on the matter I would love to know of some form of facebook development recommendations as applications, pages, and tabs all appear to behave totally different from eachother, yet it seems that they all should be doing the same thing to me? Is there any unified way to develop across all three of these things, or am I missing something?
Thanks in advance, as well as for the past help!
I think it should be:
obj.addEventListener('change',my_func);
(instead of onchange)
Straight from Facebook documentation:
The third parameter [to addEventListener], boolean useCapture is required (it does not have a default value)
That means that you should have:
obj.addEventListener('change', my_func, false);
Use the following html and your events attached with .addEventListener() start to work. This seems to be undocumented "feature".
<select name="find_state" id="find_state" onmousedown="return true;">
This also enables the event to fire first time the user changes the value of select. Otherwise it would fire only on second onchange event.
I have a select list where a change event has been bound to the element using jQuery. Something like this:
$("#someId").change(function() {..});
When someone chooses a new option in the select list, another part of the UI will change accordingly. Now this works fine when I use the mouse and click things, however, when using Watij to write my tests I need the jQuery change event to fire which it isn't doing.
The Watij test will correctly choose the select option required but the actual event does not get triggered. I have tried calling fireevent("change"); and fireevent("onchange"); to no avail. I have also tried ie.sendKeys("{ENTER}"); and ie.sendKeys("{TAB}"); which also does not seem to do the trick.
Any ideas?
The only solution I've found so far is to roll back the version of jQuery in use. I'm currently using version 1.4.1 (the offending version in regards to the testability of the change event on select boxes) and after going back to version 1.2.6 the problem goes away.
Use $('#someId').trigger('change'); to fire the event manually.
See the documentation for trigger().
When the combo/list value is changed with script the onchange is not supposed to fire. I don't know how Watij is doing that, but this is one case.
Second thing is that Watij is working with IE (as long as wikipedia is rght) and IE is putting a system control in place of Your list or combo and it might break something too. Try upgrading to IE8 which has a tiny bit better realisation of form components (eg. select finally supports "disabled" attribute in options after 10 years)
You might also be interested in a normal application GUI testing apps and use them on a browser with the webapp. Record a macro and check screenshots.