Cycling between different layers in R leaflet - r

I'm using leaflet for R.
I have a map with hundreds of layers, and I want to cycle between them by pressing a button (maybe an easyButton) or a keypress.
This means that only one layer should be visible at a time, and that pressing the button would hide the current layer and show the next one (and at the last layer, start from the first).
Yes, I can do this with baseGroups and addLayersControl, but this requires moving the mouse and then clicking to select the layers and this can be slow, since I'm going to spend less than one second checking each layer anyway.
I'm no JS wizard, but I guess some sort of JS magic should be applied here. I'd like to avoid using shiny for such a simple applet.

Related

Separate HTTP requests for each dropdown or a single request for a fat FormViewModel?

If the view which serves for creating an item contains some dropboxes / checkboxes / whatever with values from the server, should it send separate requests for filling up those controls with values (one request per each collection of data) or it is better to have a single api endpoint that returns all of the necessary data for filling up the form on front-end?
For the sake of simplicity, I've simulated here an example: Say we're building an app for a car servicing company where clients can make appointments:
Should the front-end app make 2 get requests to api/models and api/services, or these collections can be returned from the server in a single response (from api/appointments/createformdata), What are the best practices regarding to this?
Thank you in advance!
Well, since in your example, both combo boxes need values, then I would load up on first page load. There would be no need for separate requests unless those combo boxes are dependent on data in the form, and then in that case you have no choice but to wait for user input to determine that.
so, say you have two combo boxes, and the 2nd one is cascaded by the 1st combo choice? Well, the first combo box does not change - so load it up at page load time, and you have to do that anyway. No use writing out separate events or code to load that first combo that MUST be loaded in the first place.
however, the 2nd combo box? Well, since its values are based on the first one, then once again, you have no choice, do you?
So, I don't see any real use case, that if two combo boxes are independent to each other, then I see next to no reason why separate requests would be required, and that just loading up both combo boxes on first page load would not suffice here? (then you don't need ANY separate requests).
Now, if there is some kind of tab, or UI and the user can't see nor use the combo boxes right away, or may never even select say some tab out of a tab control? Well, ok, in that case then you speed up the page load by not filling out the combo boxes until such time the user gets to that part of the form (maybe some pop dialog, or maybe some kind of wizard steps).
But, once again, if the two combo boxes are not dependent on each other? Then I see no reason to use two requests or events to load up both of them. But then again, it would beg the question as to how you did in the past load up the combo boxes anyway?
I mean, if each combo box was some ajax call, then keep using two of them, and keep the two requests. Since attempting to merge, or put two ajax calls that fill out two combo boxes as one call is a pain, and does not follow a re-use design patter. The result is messy code, and worse force you to write code that does two things.
I mean, if you build a nice general routine to call + fill out the combo box, then continue to use that code to fill out the 2nd one. I would not blow up really nice working code to somehow fill out two simple combo boxes on a page and attempt to use one request for that filing out of the combo boxes.
And as I stated, if the combo boxes are in plain view from the start of the page load, then code behind on first page load is the place to do this unless some rather huge performance issue were to crop up. As a result, you now don't have ANY separate requests to fill out the combo's, do you?
But then again, a combo box is good for what, 30, maybe 50 choices tops, and after that, you need a different UI, and thus once again, you don't have a problem performance wise by doing this either way, do you?
And if you are trying to fix or avoid a performance problem? Then you putting too many choices into the combo box, and that is the wrong ui choice, and then once again, you don't have this issue, do you?

robotframework - select a region on leaflet map

I'm testing our web application which has a map inside a form. I use leaflet map to show different regions on it, region ids may change with choosing a combo-box option. I've tried click element using Xpath to choose a region but unfortunately it didn't work. Is there any way to select regions from leaflet map with Rrobot Framework?
Below is the Robot Framework code I am using:
click element xpath=.//*[#id='map-id']/div[1]/div[4]/img[89]
Here is my form:
I had the same problem, and there are two ways to fix it: create a custom Python keyword to locate the map element, find the center of the element, calculate a distance away from the center to click, and then click that location (not as hard as it sounds, actually); or click the map element itself (probably by a dom-style locator, those are fairly solid and can click behind transparent overlays) and be happy with the center of the map being the only place you can click it.
Except for the second option, this all assumes that there isn't a transparent overlay blocking Robot Framework from clicking your map, which is something else that could throw that error. If there is, then you may need to go through Javascript via the Execute Javascript keyword. Javascript is able to click things behind transparent overlays, assuming the click () command works with your current setup.
If ALL of that fails, you might consider a different custom keyword that moves the cursor and then clicks as the cursor. I don't have access to that code atm, but it's a one-line keyword in Python.
Also, the error might be just because your XPath wasn't specific enough.

Flowchart always shows all nodes collapsed, any way to expand them?

We are using a flowchart activity as base for our workflow. All the activities that I drop on the designer surface of the flowchart are shown in collapsed state. Even if I click on "Expand all" in the top right of the designer.
First I thought it's a problem with my activity designer code, but the same holds true for standard activities like Sequence: They can not be shown in expanded mode when inside a flowchart. They do not show their regular Expand/Collapse icon in the top right, too.
A little sequence inside another sequence is expandable:
But inside the flowchart, the same sequence is not:
Is that by design, intentionally, or am I just missing some very basic piece? I would like to expand individual activities (we have a lot with elaborated designers), but at the moment this seems to work only in Sequence-like base activities, not in flowchart.
I think it will be so complicated if your Flow chart has a lot of items so they prefer levels which you can see it in the navigation menu when you hit double click to the Sequence Item
and also the Same if you have Sequence WF and you added Flow Chart item will be the Same

Reactivate drag control fails in openlayers

all. I have this little Problem and i'am looking for some help:
first I have a function which contains the following:
var point = new OpenLayers.Geometry.Point(imageConfig.XPos, imageConfig.YPos);
var imageFeature = new OpenLayers.Feature.Vector(point);
layers.imageLayer.addFeatures([imageFeature]);
So a point is be drawn on the layer. On this layer there is also an openlayers drag control. It is activated after the point was drawn. Now I can drag the point around. Works like a charm.
This is a little part of a user driven step by step procedure. So after dragging is done the next steps doing something with the point. While these other steps the drag control is deactivated. In the procedure it is possible to jump between steps so the de/activate of the drag control is needed. This works fine.
At the end of all steps the point is removed from the layer. Also this works great.
BUT: if I call again the function which draws the point on the layer (of cause now it is a new one) and activate the drag control I cant drag the new point any more even if I try to select the point with mouse click?!
I controlled with firbug:
feature is there
feature is on the right layer
control is there
control is on the right layer
control is activated
Maybe I' am missing a simple thing here. But I breaking my hed on this for two days now and can't find an answer.
By the way I found that in the first step sequence (when all works great) the controls feature property is set with the point feature. But in the second not. The same in the controls drag handler feature property.
I tried to set it manually by:
control.feature = imageFeature
and:
control.handler.drag.feature = imageFeature
I was looking for a function to set the new feature to the control. But can't find any on the openlayers docs.
Other controls at not active at the same time (controlled it with firebug).
But no luck. Didn't help. Why this? I'am sure that this should work. What am I doing wrong or miss under standing here???
Every help appreciated.
Thanks
Figured it out by my self. Problem was that I used a geoext feature store to display points in a grid. This grid was configured wit a geoext feature selection model. I just copied this...
The selection model also asign a feature select control on the map. In the first round this do no conflicts to the drag control because it is loaded after.
When the the tool enters the first step again all controls are loaded to the map. the select control and the drag control is enabled. this can't be handled by open layers. It seems the last to map added control is the one which comes with priority. So you can enable the drag control after again and again. The select control wins.
The trick is to decativate the select control. Then all works perfect.

Can I suspend drawing to perform multiple successive updates in Flex?

I've written a simple calendar control to allow for selecting single days, weeks, months and so on. The simplicity comes from the fact that I don't really do any drawing myself, opting instead to create a bunch of boxes and labels to act as date cells for the calendar.
When a date or a date range is selected, I need to highlight that range. It's easily done by iterating through the cells and switching their style. [edit:] However, this seems to cause a delay during which the cells are first drawn as if the style name was blank, and then re-drawn with the correct style, despite the fact that I never explicitly set the style to null -- I alternate between "CalendarCell" and "CalendarCellSelected".
If this were Windows Forms, I'd call SuspendLayout on the parent container to make sure the controls are repainted only after I've finished the updates. What I'm looking to know is whether or not a similar solution exists for Flex. I'd like to avoid drawing the entire calendar "manually", so to speak, if that's at all possible.
edit: changed the problem description to more accurately reflect what I'm seeing.
Are you using callLater() at all?
If you use callLater() it may impove your visuals as it batches up changes until it needs to draw a frame or you force a frame draw with validateNow() or similar. It might be enough in your case.
Is your calendar control a UIComponent? Is it using the standard invalidation methods like commitProperties(), updateDisplayList(), etc?
What you might want to do is keep a private array of the cells that will have their styles changed, but then do the actual style switching in your commitProperties() override. I'm just not sure if setStyle() fires an validateNow() because the flickering is a bit surprising.
This may not be exactly what you're looking for, but David Coletta at Adobe has posted a video explaining an EventCoalescer that they use in Buzzword for deferring events that update specific areas of the app UI until the user has stopped moving the insertion point in the text, for example.
This blog post by Hans Van de Velde also has a similar solution, and actual code for it as well.

Resources