How do I toggle the Mouse Wheel Zoom functionality?
I know you can set the mousewheelzoom default at map creation:
interactions: ol.interaction.defaults({
mouseWheelZoom: false
}),
But how do I change it once the map is created i.e. when user clicks the map I want to run a routine which switches mouse wheel zoom back on?
I know this was tricky in Openlayers2 - you had to cycle through the controls:
function PMA_Mapping_Enable_Mouse_Wheel_Zoom(map) {
//Need to go through all controls - don't know why!
controls = map.getControlsByClass('OpenLayers.Control.Navigation');
for (var i = 0; i < controls.length; ++i)
controls[i].enableZoomWheel();};
Don't know if that helps but thought I should include it.
Does anyone know how to achieve this in openlayers 3?
Mouseweel is an interaction not a control.
so, you can always use the
interaction.setActive(true), interaction.setActive(false) to toggle the interaction.
Start your map initialazation like so:
......interactions: ol.interaction.defaults({
mouseWheelZoom: false
}), .......
Then once your map is ready create the mouseWheel interaction like so:
var mouseWheelInt = new ol.interaction.MouseWheelZoom();
map.addInteraction(mouseWheelInt)
and then toggle it :
mouseWheelInt.setActive(!mouseWheelInt.getActive())
Related
Currently it is possible for me to manually trigger hover event of highcharts like below code to show tooltip and highlight the series.
chart.series[0].points[2].onMouseOver()
However the state can be easily changed after moving the mouse.Is there a way for me to keep the state?
If you want to keep your tooltip visible when mouse pointer is out you need to disabled tooltip.hide functionality.
Highcharts.Tooltip.prototype.hide = function() {};
and highligt point again after mouse out:
events: {
mouseOut() {
let series = this;
series.points[2].onMouseOver();
}
}
Demo: https://jsfiddle.net/BlackLabel/xjzc25aL/
For those who are simply trying to make the tooltip visible for a longer time, there is the hideDelay property.
For example, to make it last 5 seconds you can write
chart.tooltip.options.hideDelay = 5000;
Please have a look at
www.jsbin.com/wigokojina/1/edit?html,css,js,output
I've added custom svg icons to the konva transformer, but the middle rotator icon is draggable even if i set draggable to false. The two other icons are fine and as expected, as far as dragging is concerned.
My questions are:
How do i disable the dragging for the rotator anchor, so that the icon doesnt move?
How do i disable all event handlers for an anchor, and add one click event? Ive tried shape.off('dragmove') etc. The only thing that helps is setting listening to false, but then im prevented from adding a new event listener. I want to disable all event handlers for the top right anchor, and add one onclick listener afterwards.
Is it possible to add the icons to the shape itself using fillPatternImage? Instead of adding the icon as a new shape like im doing. If its possible, please provide an example using the jsbin.
Thanks very much :-)
At the current moment konva#4.0.16 doesn't support fully customized Konva.Transformer. But you are making a good attempt.
How do i disable the dragging for the rotator anchor, so that the icon doesn't move at all?
You can reset the position in transform event (almost as you do it). But at the current moment, for performance reasons, inside transform events all anchors has "old" positions. So you see dragging of the icon from rotater anchor. To fix the issue we can force update a transformer:
circle.on('transform', function(){
transformer.update();
for (var button in buttons) {
var selector = button.replace('_', '-');
var shape = transformer.findOne('.' + selector);
var icon = transformer.findOne('.' + selector + '-icon');
icon.position(shape.position());
icon.x(icon.x() - 5.25); icon.y(icon.y() - 5.25);
layer.batchDraw();
}
});
How do I disable all event handlers for an anchor, and add one-click event
It can be something like this:
shape.listening(false);
icon.on('click', () => {
alert('delete');
});
Demo: https://jsbin.com/galetahara/4/edit?js,output
I have a map where a user can choose some object/feature on the map and draw a line to another object/feature. When the user selects the feature i would like do add a draw interaction and already set the first point to the selected feature without the user having to click again on the map.
Here is a fiddle: Sample
The commented code below should be executed programmatically without user interaction, after pressing the draw button
geometryFunction: function (c, g) {
if (goog.isDef(g)) {
g.setCoordinates(c);
} else {
// DO THIS AUTOMATICALLY ON PRESSING DRAW
// TO INITIALIZE AND START THE DRAWING PROCESS
c[0][0] = 1174072.754460305;
c[0][1] = 332653.94709708635;
g = new ol.geom.LineString(c);
}
...
}
The current behaviour is that you click on the Draw button and can click on the map to start drawing (but i overwrite the first node with my desired starting location -- in this example near central africa)
Is it possible to click on Draw and the first node is already programmatically set, without having to click on map first?
It is not currently possible to do manually append points to the OpenLayers 3 ol.interaction.Draw, but it would make sense to be able to support it (in my mind). It would be "as-if" the user had clicked.
You should ask the OL3-dev mailing this about adding such a feature to see what they think about it. If they agree and you're willing to work on this, you could provide a pull request. See: https://groups.google.com/forum/#!forum/ol3-dev
If you don't mind using a private method in OL you can do this to achieve what you want.
var event = $.Event('click'); //create a click event in your draw method using JQuery
event.coordinate = [1174072.754460305,332653.94709708635];// set your starting coordinate
draw_interaction.startDrawing_(event);// tell your interaction to start drawing
I have a user control in my wp7 application which contains two text boxes and two buttons. I need to show it like the keypad opens. How can I do this?
You can use the transition effects .
SlideTransition sltrans = new SlideTransition();
sltrans.Mode = SlideTransitionMode.SlideUpFadeIn;
ITransition transition = sltrans.GetTransition(yourcontrol);
transition.Begin();
transition.Completed += delegate { transition.Stop(); };
You can set your transition effects to any user control by binding them in code behind.
I think this might suffice your requirement.
Google maps API show a message over the map when user scroll with mouse over the map.
The message advice the user must press control key while scroll with mouse over map.
This is a very nice solution to preserve normal page scroll with the mouse.
How can We do this in open layer 3+ API. Is thus possible? Please a need this behavior.
Thank you in advance.
Here the answers to your questions:
How to detect that the user is doing scroll on the map with the mouse and show an alert that you must press control key?
map.on('wheel', function(){
//write whatyou like and add it in popup window
});
How can you make it so the zoom on the map can only be done by pressing control in addition to scrolling with the mouse?
OpenLayers doesn't have this functionality but you can do it by changing ol.js as you want.
A helpful similar function can be found here
Also, you can do it with only (shift key) or (alt key)
map.on('wheel', function(evt) {
map.on('wheel', function(evt) {
wheelZoom(evt);
});
function wheelZoom(evt) {
if (ol.events.condition.shiftKeyOnly(evt) !== true) {
evt.browserEvent.preventDefault();
}
};