API for continuously redrawing polygons while panning? - leaflet

Is there a way method in the API to force the SVG polygons to re-render while I drag? As opposed to rendering a clipped version that re-renders when I finish dragging?
I tried to run .redraw() in the onMove callback, but that didn't solve it for me- so I assume redraw doesn't actually rerender?

Related

Edit camera center directly and instantly in Mapbox GL JS

I want to edit the camera center directly in Mapbox GL JS. I know about the existence of the map.easeTo and map.flyTo methods but I do not want to use them because I have to do multiple requests to them (around 60 per second), which in turn results in decreased performance because transitions are stacking upon each other (only an assumption from my side).
Essentially, instead of doing map.flyTo or map.easeTo, I want to do change the camera center directly and instantly. Alternatively, I would like to know if it is possible to remove all the previous transitions before calling map.flyTo or map.easeTo.
To update the camera without an animation use Map#jumpTo.
If you're trying to do your own smooth camera animation you might want to also use requestAnimationFrame like in https://docs.mapbox.com/mapbox-gl-js/example/animate-camera-around-point/

Core Plot show 'Loading' spinner

I am using core plot (0.4) to render a graph and it is working fine. However (especially when on the iPad) the graph can take a while to render. I have added a UIActivityIndicatorView to the graph which shows up when the graphs starts to be drawn, but I can't find any event to hook that I can use to stop the spinner.
I have tried using the numberForPlot method and detecting when the last datapoint has been requested, but this is called multiple times for each line on the scatterGraph, so I can't easily use this. Is there any sort of graph rendered event that I can hook for this?
If you're doing [graph reloadData] to update the graph, can you just bracket that call with your indicator start/stop calls? I think that core-plot does everything in the main thread.
Core Plot uses Core Animation for all rendering. A single graph contains many CA layers that are rendered independently. -reloadData just tells the graph to update its data cache next time it draws and tells Core Animation that it needs to be redrawn. Similarly, just bracketing the data source calls only captures the data caching that happens before the render. You would miss the actual drawing time and would never know if Core Animation re-rendered the graph at another time, such as after a resize.
If you only care about the time to render the plot and not the other parts of the graph, one way to do this would be to subclass CPTScatterPlot and override the -renderAsVectorInContext: method. Bracket the calls to super with your activity indicator code.

How do I know when a CATiledLayer has rendered all visible tiles?

I am working on an application where I render PDF content in a CATiledLayer. I want to trigger one method after the rendering of the tiled layer is complete.
Is there any delegate method that will be called immediately after the rendering of all visible tiles is completed? Is there any other way of knowing when this is finished?
You can calculate the number of tiles your drawing requires before it's drawn. In drawRect of the tilingview, each tile is drawn only ONCE. So put a counter in part of the draw rect that calls a new tile. When your counter reaches the total number, call your method.
Keep in mind that drawrect for tiling is done on a background thread.
This requires some creative thinking. I've had a similar problem where I've needed to abort the rendering of a tiled layer mid-cycle. The way I worked round it is somewhat complex, but seems to work reasonably well. It involves wrapping the draw calls to the tiled layer inside a NSThread. Threads have a isFinished bool that you can key-value observe to discover when a tiled layer has completed its render.
If you're not comfortable with threading on iOS this may be more trouble than its worth, but will give you the advantage of knowing when the rendering has finished, and also being able to cancel the thread operation (and thus the render) if required.

Making a GWT widget transparent to events

I'm trying to draw a map, with some text annotations on top.
I've got this all working, but the text annotations (which are Label widgets floating over the top of the GWTCanvas which the map is drawn on) are soaking up any events which I'd like to get passed through to the canvas underneath. This is particularly obvious when the user drags the map; moving the mouse pointer over one of the widgets cases an Out event to be sent to the canvas, thus ending the drag.
Is there any way I can tell the Label not to respond to any events, and instead pass them on to the widget underneath?
Belated edit: turns out that pointer-events: none does what I want; but it's pretty new and may not work on some browsers...
No. The only thing you can do is catch the events and pass them through the event handler.

can't draw fast enough to keep up with touchesMoved?

I am trying to implement simple paint functionality in my iPhone app. I tried updating a bitmap with a bitmap brush, and I also tried this tutorial.
Both methods have the same problem, even though the code is almost totally different. It happens only on the device - the simulator works fine.
When I touch the screen and move my finger, the screen does not get updated. When I pause or lift my finger, then the screen gets updated. This is not a very good user experience!
I tried calling drawRect from touchesMoved directly, but found that the drawing context (which I retrieve using UIGraphicsGetCurrentContext) is invalid for many of the calls, so painting the screen myself for every touchesMoved doesn't work.
Any ideas?
Thanks for any help, this has been quite frustrating!
Henning
It sounds to me like you're not giving the main run loop a chance to update the display. Your drawing code may be taking longer to execute than the time between touch events, so the display is never updated. When you lift your finger, it does the updating because it's no longer burdened with your drawing.
You might consider optimizing your drawing to speed it up (drawing only within the dirty region of the screen, for example), using something like NSOperationQueue to queue up the heavy calculations of your drawing to run on a background thread, or selectively dropping touch drawing events to keep your response smooth.
One additional possibility is placing your heavy drawing code in a separate method and calling it via performSelector:withObject:afterDelay, with a 10 millisecond (or smaller) delay. This might give the main run loop a chance to update the display with its current state. I haven't tested this, but if I remember correctly I've seen this work.
You can't directly call drawRect:. To refresh your screen on demand, try calling [self setNeedsDisplay] from your touchesMoved method, which will setup the proper contexts for a call to drawRect:.