I want to display a route between 2 or more coordinates. I don't want any fancy direction instructions or start and end markers. So basically something like a <Polyline /> that goes along roads. I know there is a leaflet-routing-machine, but I wasn't able to make it work using React and Typescript.
What is the best way to do that?
Edit: I have tried this but I don't know how to edit the L.Routing.Itinerary properties which I need to edit to disable the directions instructions and the Marker style.
You need to add two things to achieve that behavior:
1.According to the maintainer add this to make routing panel dissapear on styles.css.
.leaflet-control-container .leaflet-routing-container-hide {
display: none;
}
2.Add this to make markers dissapear when you create the routing control instance
createMarker: function () {
return null;
}
Demo
I keep getting emmett autocomplete suggestions even inside the template string used with styled/css/createGloablStyle when using styled-components. Is there a way I can get around to disabling emmett inside the function template string or maybe at least push it down the suggestions? It's not a problem per see but I have been exploring vscode and want to know if there's a setting that helps.
Image attached below for reference. The body tag I want to disable in autocomplete suggestions.
PS: I don't want to disable emmett globally or even in the file, just in the function scope.
I want to be able to set a keyboard shortcuts for buttons in an application I'm building. I'd like to be able to pass in the keyboard button code as a parameter to make it configurable. Here's what I have so far using the documentation before I got stuck. HTML:
<div ng-controller="BtnCtrl">
<button class="primary-btn" type="submit" ng-keypress="press($event, '12')">Button</button>
</div>
JavaScript:
angular.module('App')
.controller('BtnCtrl', function ($scope) {
$scope.press = function($event, hotKeyRef) {
if ($event.keyCode==hotKeyRef) {
//need some code here to trigger the button press
}
}
});
So using my approach, I'm unsure of a) how to trigger the button press from inside the function and b) whether this is the correct way of passing in the keyCode data.
I might also be taking completely the wrong approach, so any other guidance would be appreciated.
Thanks
For the question a).
The main uses of a < button > html element is to fire an event on a click.
So if you want to use a keypress, why use this element ? I don't really see what you want to achieve. that seems controversal.
for b) :
By default, ng-keypress is intended to be used in an input element.
Otherwise, it seems that some posts, where I inquired, manage to make it work out.
You can see what it can look like, for example on this post (Is it possible to listen for arrow keyspress using ng-keypress?)
in which the person trying to setup the konami code.
Moreover, it seems that you can have trouble depending on which browser (Chrome, Firefox, Safari, IE) you uses. Be careful.
I hope this could help you.
hi there is an excellent plugin for your scenario u can check the below link
https://github.com/chieffancypants/angular-hotkeys/
u can also check the below stackoverflow link
What is AngularJS way to create global keyboard shortcuts?
"https://maps.googleapis.com/maps/api/staticmap?size=440x420&scale=2&style=feature:all|element:labels|visibility:off&markers=color:green|size:small|90,-180"
So I have something like the link shown above. That link doesn't quite work, all I did was shorten it down to 1 coordinate and using a possibly not correct coordinate.
BUT, you should get the idea. Should I be able to instead do something like this:
<div id="mapWrap" ng-controller="EdwardMap">
<img src="https://maps.googleapis.com/maps/api/staticmap?size=440x420&scale=2&style=feature:all|element:labels|visibility:off&markers=color:green|size:small|{{building.mapcoord}}" usemap="#Map">
I have attempted it and I cannot get it to work. I have other code below it that uses the same controller and is working fine, but I was hoping that Angular could help me generate the image! And incase you think something is wrong with my image link, the one I am using is otherwise working perfectly, it just has more coordinates and other goodies. I took one of them and replaced it with {{building.mapcoords}}.
Here is where building.mapcoords is coming from:
$scope.building = [{
name:"name2",
mapcoords:"80,-170",
address:"address2",
htmlcoords:"556,69,565,72,568,75,568,85,564,92,559,100,557,108,554,98,550,92,546,86,546,76,552,69",
},{
name:"name1",
mapcoords:"",
address:"address1",
htmlcoords:"699,270,708,274,710,277,710,285,707,291,702,300,699,308,696,300,693,292,689,287,688,276,694,271"
}
Thanks!
Try to use ngSrc Should work fine, because you make another request to the url, think of it as just a resource, a different image
I want to let the user crop an image, I found this JQuery plugin - http://deepliquid.com/content/Jcrop.html
I tried to use it with Angular-ui's Jquery passthrough option, adding the ui-jq=Jcrop directive to the <img>
The problem is that If I use ng-src to dynamically change the image it doesn't work and nothing is seen. If I change it to src and put a static url I can see the image and Jcrop.
how can I fix that ?
also, how can I listen to Jcrop's callbacks to know what is the user's selection ?
is there a better / simpler way to add image cropping functionality to AngularJS ?
Here is my solution:
I've written a directive that create img element and apply plugin on it. When src is changed, this img is removed and content that was created by plugin is also destroyed and then re-created new img with new src and again applied plugin on it.
Also provided 'selected' callback to be able to get coordinated that were selected (wrapped in $apply so you can modify your scope values in it).
Check my solution at Plunker
I've built a demo using AngularJS and Jcrop here:
Demo: https://coolaj86.github.com/angular-image-crop
On Github: https://github.com/coolaj86/angular-image-crop
You can leverage ui-event to create an event definition object with the keys being the event names and the values being the callbacks. Or you can simply pass these events as options to Jcrop (according to the documentation)
Finally, there is a new update coming to ui-jq that lets you add ui-refresh which is an expression to be watched to re-trigger the plugin.
Theoretically you should be able to do
<img ui-jq="Jcrop"
ui-options="{onSelect:myCallback}"
ui-event="{onChange:'myCallback($event)'}"
ui-refresh="imgSrc"
ng-src="imgSrc" />
Note: this simply re-fires the passthrough again, and doesn't automatically mean this will fix the problem or that the plugin will behave properly when re-initialized
We're still working on a good way to allow you to trigger different events at different times.