Add empty overlay to leaflet map? - angularjs

Looking for a way to add an empty overlay to a Leaflet map. I have multiple Leaflet overlays that load in their data from a realtime server. Because I am using a custom UI control and not the default Leaflet one, I have a listener that every time new markers are created, checks to see whether their associated layer is active, and if it is, adds the markers to that layer.
$rootScope.on('newMarkers',markers)->
type = *fn to find type*
if mapFactory.currentLayers[type]?.active
mapFactory.addLayer(markers, type)
)
I don't think building in logic to see whether it's the first time a marker is being added to that layer makes sense, and would rather create an empty layer and add data to it after. I know you can do this with the L.geoJson type, but this layer is made entirely of plain markers. Any suggestions

You could use L.LayerGroupfor this:
Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.
Reference: http://leafletjs.com/reference.html#layergroup
Or L.FeatureGroup:
Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.
Reference: http://leafletjs.com/reference.html#featuregroup

Related

Reference a combobox within a grid with a cell editing plugin in Sencha Test (without global search)

Given there is a Grid using a cell editing plugin is there a way to reference a combobox editor without doing it in a global way ?
I have this working:
this.grid().rowAt(0).cellAt(0).click(); // click to show the combo
ST.comboBox('combobox[itemId=someID]').expand().setValue(1); // this works but looks for the combo globally
BUT I think I should be able to do:
this.grid().gotoComboBox('combobox[itemId=someID]'); // this doesn't work
or something like:
this.window().gotoComboBox('combobox[itemId=someID]'); // this doesn't work either (grid is within a window)
All of the goto() methods ultimately use Ext.ComponentQuery/down() to traverse the component hierarchy to resolve the future's component. If you were to try this yourself apart from the ST API, you'd find that you can't get the instance of the combobox by doing down() on the grid or its parent (e.g, grid.down('combobox[itemId=someId]').
I think a nice feature would be to have some apis in the row/cell futures that would enable specific actions on editors. It's an area we see a lot of questions in, so that would probably be a more robust solution. I'll add a feature request for it.

AS3 / Animate CC: user can edit table contents

This question relates to strategy rather than specific code. I'm struggling to think of a viable approach and I'm hoping somebody may have encountered a similar challenge.
I'm building an Animate program that will:
Enable the user to draw a line on the stage (by means of a series of mouse clicks).
Capture the coordinates of each mouse click in an array, and add them to a table that is displayed and updated in the UI.
Display the resulting line.
Enable the user to edit any of the coordinates, and update all of (1) (2) and (3) accordingly.
The first three steps are working OK, but darn ... how should I make that data editable? I've put a listener on the textfield that holds the set of coordinates, but I think that's a dead end. It's just a string with line breaks, so it would be hard to edit a particular few characters and have AS3 / Animate detect what had changed.
Is there a good technique for this?
Background: was comfortable with AS1, skipped AS2 completely, and now (12 years later), I'm grappling with AS3. It's been frustrating, but ... I've built a package and it's working.
The most important concept you need is the Model-View-Controller design pattern.
model
Start with defining your model which represents the data in your application.
Do so according to your requirements.
The minimum requirement for an object to work as the model is that it notifies others when it got changed, because MVC is based heavily on the observer pattern and you want to observe when your data changes. In As3, using the built in EventDispatcher makes sense.
In your case, a nested model makes sense, that is, you have a model for each individual point and then another model that acts as a collection of all points.
Add methods to your model classes to modify the data. You want to add and remove points to the collection of points and you want to modify the coordinates of each individual point.
view
Each view receives a reference to the model object that represents the collection of points. One view might draw them into a coordinate system and connect them with lines, another might be a tabular representation.
controller
The controller knows about the model and reacts to user input on the view.
For example, when somebody clicks on the view, a new point is inserted.
Given the simplicity of your application, it might makes sense to combine view and controller, so that each view directly manipulates the model.
how should I make that data editable?
By creating methods on the model that allow you to do exactly that.
Say for example the LineView class receives the PointListModel which includes all points and stores it in a private variable
public LineView (pointList:PointListModel)
{
list = pointList;
Now it will create graphical assets to represent the points, based on the list (this should be executed whenever the PointListModel object signals a change:
private onListChanged(event:Event):void
{
for each(var point:PointModel in list)
{
// draw circle or whatever
As the creation of each visual asset in the view is based on the model, it should be possible to connect them. When the user now modifies the visual asset, the made modifications can be applied to the PointModel object. Remember: any modifications made to a model will cause it to dispatch an event that it was modified. This will inform all other views that this point was modified.
This is how dragging & dropping the circle representing a point in one view will make the coordinates of that point displayed in another view update as if they are linked together, because they are: via the shared model object.
I am still a bit hazy about how I would associate the displayed table with underlying array data. Should I make each row of the table a separate textfield with an associated listener?
This is up to you.
You could make the entire table only listen to the change event of the model that represents all points. This would cause the entire table to be updated.
Or you could make the table observe the point list model to add or remove table entries and each entry in the table observe a point in that list. This allows you to only update a single entry in the table if only one point got updated.
Keep in mind that the components of flash do a lot of this for you. Flex has even more sophisticated components. The way each entry is rendered can be defined with a custom itemrenderer.

Getting X11 mouse click & position when using XtAppMainLoop? (improving xload)

How can I register a callback to get mouse right button down and up events?
Background: The xload application that comes standard with many UNIX flavors is almost handy. It draws a graph of system load by time. It uses a simple StripChart widget that is flawed; it draws the grid wrong. I've fixed that, but now I want to be able to click on the strip chart graph and get the time corresponding to that load.
The source is here: http://learjeff.net/forums/xload .
The main sets things up and calls XtAppMainLoop. I want to know how to register (for the child StripChart panel) a handler to get mouse up-down events, and how to find the mouse location in the panel on the down events. I'm not an X11 programmer; I'm just hacking an existing program. The last time I did GUI programming was pre-X11 (SunWindows). I did once modify X11 to run over OSI TP4, but that didn't require much knowledge of widgets. Any and all help appreciated, including pointers to the right functions to look up. Thanks!
Meanwhile, feel free to use my modified xload app. You'll have to guess what the numbers on the label mean.
The program is written using X Toolkit Intrinsics and Xaw.
You want to add one or more actions to the widget in question (the actions field in the core of struct stripChartClassRec) and one or more translations (the tm_table field).
Actions are C functions called in response to abstract events that you, the widget writer, define (like e.g. startDragging() or pageDown()). Translations map these abstract events to concrete events that Xt understands (like e.g. <Btn1Down> or <Key>KP_PageUp).
Inside the action you have access to the XEvent struct that has triggered the action, and from there you can get mouse coordinates or whatever.
To see how actions and translations are set up, look at one of the existing Xaw widgets, e.g. Panner. You can download the Xaw source here.

MVVM - dynamically create multiple instances of view/viewmodel

I have a requirement to display a number of graph/chart "thumbnails". Clicking one will show an "expanded view" (in a separate panel) that displays a larger version of the chart, plus controls to view and manipulate the chart.
There will be a number of different charts, each plotting my data in different ways. Also, a given chart type may appear several times, each plotting a different subset of the data. The controls in the "expanded" view will also differ from one chart type to the next, so there is little commonality here.
I'm struggling to get my head around how to model all this in MVVM, especially given the need to dynamically create an unknown number of thumbnails (and in some cases multiple instances of the same type).
Thinking aloud, I guess I need a view/viewmodel that represents a single thumbnail (the view contains the chart component and the VM exposes the data to plot). I guess I also need a V/VM for the "thumbnail list" UI, responsible for creating the thumbnails and exposing them via a collection for binding to the list. But how does it instantiate these? A VM gets injected into its view, suggesting the "thumbnail list" VM would have to dynamically instantiate the thumbnail views - but a VM shouldn't have knowledge of views should it?!
Lastly, when I display the "expanded" view, it would make sense to (somehow) pass it the charting component/view that was used in the thumbnail, to avoid having to render the chart again, but how?
If it's relevant/helps, I'm using Castle Windsor for dependency injection, and the navigation features of Prism.
This is indeed a complex topic,...
I would suggest a VM for the list of icons not necessarily for the icon itself. this can be bound to properities of the IconListViewModels. Then you should think about a ChartViewModelFactory. Which works in conjunction with your DIC.
An important discussion is the VM-V marriage. View first or View Model first... one way could also be ViewResolver if which returns the matching view based on your view model... this can rely on some sort of conventions. So the final steps could be ask the factory for a view model find the matching view glue them together and bind them to a content presenter...
I hope this helps to get you started...

Where do I instantiate my Objects in CRUD n-Tiered WinForm App?

Say I have a WinForm CRUD(like) application. I want to follow best practices on this so I try and make it follow OOP and a n-Tiered design.
Unfortunately I am familar with the words but not the practice of them. So lets go with the following example: My CaseNote program. I have a tabbed application where you go to the search tab to find a member and then one of the options is to go to the CaseNote tab to create a new case note, look at existing CaseNotes, or create a follow up CaseNote to a Parent Note. All of this is for the member you selected from the search tab.
So if I am creating objects and passing them around to be used by different forms where should I be instantiating them? I had thought I would have 3 layers; UI, Object, DAL. Where I fall flat is where I instance tho objects. I can't instance them in the object layer, can I? Also, if I instance them on the form how do I pass them from form to form in a quite large app?
CaseNotes Screen Shot
If you want to look at some more words around this problem you want to look at MVP and MVC. (These stand for Model View Controller and Model View Presenter). Some people will shoot me down for saying this but they are quite similar in concept.
The aim of MVP and MVC is to allow you to design your application logic without even having to think about your application apperance. It also allows you to define your user interactions without implementing an actual GUI. Esentially your model is your application logic, your data, your classes which actually do stuff like talk to your database. Your presenter or controller is what interacts with your model and what controls your user interface and reacts to user operations on the interface. Finally your View is your winforms design or your web page.
I'm sure you will be able to find plenty of material on the web about this but to give you some concrete help with this problem should serve to inform and illustrate your reading.
The first thing you need to do is start creating your objects that represent your data. So you will have a CaseNote object which is contains the casenote data. You will have a case note data container of some sort such as a case note database. You can define the logical operations and properties of these as if they where real items.
Then you would move on to define your presenter or controller which will define the operations that you want to support from the GUI. At the same time you should define an Interface that will define for the presenter/controller what operations is can perform on the GUI. So for instance your presenter may expose a method called SearchForCaseNote which takes a string parameter. Your view Interface will expose a method called DisplayCaseNote. When a user clicks on the search button the view will pass through the command to the presenter which will then call the model to get the data. The presenter may format the data at this point, i.e. convert DateTime object to a string and then pass the data back to the view through the interface define method called DisplayCaseNote.
You don't have to use the View interface, you could call into the view directly, but having the interface means you can have many different view implementations.
One last thing i need to mention is where you create these different parts of your application. My view is everything thing should fall out from the presenter/controller. So when you application starts it creates the presenter/controller object which then create and displays your view passing itself as a variable to the view. The presenter/controller can then either create the initial models by loading them from disk or ideally discover them through a dependency injection container like unity. In fact using unity to discover the view implementation is probably a better idea again as it gives you true seperation between view and presenter/controller. When you come to move to another view, (i.e. open another window), your presenter/controller should expose a method such as DisplayDetailPage which the view calls when a button is clicked. This would create the presenter/controller for the next view which would in turn create the view and get a reference to the model.
Hope this helps.
I think you should use the RocketFramework

Resources