How to utilize Angular 4 components when creating Leaflet Extended Control? - dynamic

I am working now a few weeks with Leaflet and Angular CLI on a project involving geo map and in-door maps (Leaflet custom maps).
The application is conceptually very simple. I have to provide the user with a list of in-door locations (e.g. room) in a form of a simple location tree table, where, on user click, a new in-door map must be called. Also, I have to make a custom search box with a few filtering options for searching through sets of structured data and plotting the data on the maps in a form of Leaflet markers.
The question I have is the following: What would be the best way to implement the 2 above mentioned controls (location tree and search box), taking into account the nature of the app and the technology I am working with (Leaflet library and Angular CLI (angular 4.x))?
From my point of view, I can see 2 options by now:
1) Create the controls (location tree and search box with filters) using Leaflet L.control.extended (negative(-): seems to me that I have to statically type html in the L.control.extended 'onAdd' function in order to create the controls -> no possible Angular 4 templating engine advantages)
2) Create the controls using Angular 4 Component's templates, in Angular 4 fashion, neglecting the very existence of Leaflet L.control.extended (negative: It seems to me that this option unnecessary complicates the app + intuitively seems wrong since Leaflet extended control seems 'as born' for such types of problems)
It would be great if I could dynamically nest Angular component inside Leaflet custom control somehow. Any suggestions?

Related

DOM manipulation through VanillaJS in VueJS Framework

I've started using VueJS a month ago. I've watched many tutorials to learn the language, but generally I never see developers using the DOM methods such as getElementById or getElementByClassName to make manipulations onto an element that is inside of a component or inside a view.
I'd like to give an example to make my statement more clear.
For example lets suppose that we have a nested component called UsernameInput that is an input[type="text"].
Instead of having to pass the value through the #input directive, we could get the value from the parent using the document.getElementById(/* Id Of The Input /*).value . I know that Vue uses the Virtual DOM for the rendering to make it faster. But does using VanillaJS affect it in any sort of way? And why is it so rarely used in front-end frameworks

vuetify pagination add custom features (slot/template)

I'm using the VueJS Vuetify framework and I need a pagination option with more features then the basic one available.
what am i looking for:
an option to add custom names (not just numbers)
a tooltip over the buttons
to disable/enable just some of the buttons
pagination - meaning: use next, previous and "..." if there are too many pages
if the pagination had a template option (slot) that would of been perfect.
now i am wondering how is the best why to get my goal. is there a way to add templates to vuetify? is there a different component that has this options on the pagination?
Read the api here In answer to your questions:
1+2+3 This is not supported in vuetify out of the box and therefore you may want to consider writing your own pagination tool or looking for a different package.
4. This can be set in the props as described in the docs above, see total-visible prop and length.

Nuxt generated HTML and JavaScript does not work everywhere

I'm using Nuxt to build a component library for use with the various CMSs that my company uses. Basically, I want to use the generated HTML to create reusable widgets for the CMS. The CMSs in question can't use Vue components directly because the client's admin area doesn't play well with Vue (for example, the inline editor in Kentico 12 does not work at all with Vue and our clients require this functionality).
Using Nuxt to build the component library works great as long as the components don't DO anything. However, if I want to create an accordion that has an #click event, it doesn't work when loaded into the CMS. I narrowed down the issue:
A) http://example.com/Accordions/
B) http://example.com/Accordions/index.html
Case A works fine. With Case B, the page loads but none of the scripts work. The events do not fire at all, and I'm getting the following error:
"DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method."
The Accordions component doesn't work on any page that is not http://example.com/Accordions/.
Nuxt is generating the Accordions/index.html page so I'm assuming it's connecting the route with the functionality in the JS, but I'm not sure exactly what the problem is, what to search for or how to fix it. I've been searching for hours. Can anyone help me with this?

Change Leaflet js map colors with vue js [duplicate]

It's been a few days now that I have been looking for a way to be able to dynamically change the colors of different map features such as Roads, Water, Buildings, Background etc using leaflet.js. I know we had this option in Mapbox using the Mapbox GL. But I am wondering if this can be achieved using the leaflet.js library.
Any help/workaround would be highly appreciated.
Thanks
By default Leaflet can render only raster tiles (i.e. plain images, which you cannot easily modify) and vector shapes (typically from GeoJSON data).
If you want to modify the tiles rendering, you have mainly 3 options:
Download OSM data and re-render the tiles (i.e. create your own tile server) using your own styling. OSM wiki should have some pages that explain how to do so.
Use an online service that offers tiles rendering with custom style (e.g. Mapbox).
Use Leaflet.VectorGrid plugin with downloaded vector data from OSM and providing your own styling.
If you want to be able to modify the rendering at runtime, then only the 3rd option would be appropriate.

What is the point of getEl() in extjs4

I have a listener that is called when a tab is activated.
, listeners: {
activate: function(tab){
var first = tab.down('input'), // will be null
firstEl = tab.getEl().down('input'); // will contain first input element
I'm not having a lot of luck understanding the relationship between tab and tab.getEl(). If this was jquery, $(tab) would give me a jquery element which would largely expand on my set of options. extjs seems to be almost backwards in this regards, or at least more complicated.
I'm trying to understand when and why I need getEl() so that it is less of a development crapshoot about what will and won't work. In other places I do things like:
showFieldHelpOnBlur = function(ctrl) {
ctrl.up('form').down('#helptext').update("");
}
without the getEl(). In this case form is an element tag just like input (above), but I don't need the getEl() before I use it. In general the two sets of functionality that share the same names but don't work the same are frustrating, and the docs don't seem to give any clue as to why there are multiple methods with the same names that do different things, or do similar things in a different way.
Found some similar issues with focus(), but those might make more sense if I just understood why are there are 2 seemingly parallel sets of methods for what are essentially DOM elements wrapped in additional functionality.
I think at the core of your confusion is how you approach the development using ExtJS vs JQuery.
JQuery is all about DOM manipulation and low level API. ExtJS approach is very different, it wants you to think of your page structure as a hierarchy of ExtJS components that are responsible for rendering appropriate HTML. So ExtJS is essentially saying: "Don't worry about html, we'll take care of it - you focus on the larger components, layouts, events, etc. "
You will say "Whoa Nelly! What do you mean don't worry about html? I want control!" And ExtJS will respond OK - we have a wrapper object called Element (http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.dom.Element) you can use it to do DOM manipulation just like you are used to with JQuery .. but be cautious. Because if you manage your own HTML we can't be responsible for what happens to your layouts and components that are not managed by the framework.
My advice is this - when in Rome do like Romans do :)
If you are going to be using ExtJS to build apps - embrace the way ExtJS is designed to work. Learn the different layout mechanics and numerous component types available to you out of the box. Use the MVC development pattern to beautifully organize your code. Use the examples to your advantage. Study the architecture and component guides - these are very useful. Understanding ComponentQuery class is a must (all those up/down methods and query).
At the end, when you have gained comfort using ExtJS components and their style of development you will be very efficient at building your UI compositions and can build much more complex applications than before.
Good Luck!
Pro Tip: Do yourself a favor and get Illuminations for Developers plugin for Firebug - it will open your eyes to see things using component structure rather than HTML elements.