Loading new pins on MKMapView as user scrolls and zooms using AFNeworking - mkmapview

Initially I load 10 pins using AFNetworking and plot them on the map and set the map zoom level to fit these 10 pins, however in my database I have 1000 pins and I want to load them as the user scrolls or zooms, how would I go about doing this?

I develop similar app. In my case, I load new pins in regionDidChangeAnimated method.
func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool) {
// load new pins
}
As you know, this method is called by the user scrolls or zooms.

Related

How do you fetch data ( Polygons / Data Pins ) on zoom in and zoom out?

Is there any way by which I can zoom in or zoom out in Azure Maps and get data of all the polygons and data pins in the current window?
After the map has finished moving you can call map.layers.getRenderedShapes function to get all rendered shapes in the current view. You can find documentation on this function here: https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.layermanager?view=azure-iot-typescript-latest#getrenderedshapes-position---point---boundingbox--array-string---layer---expression-
If you zoom the map in close enough into an area in the following sample, it loads a list of all locations that are in view, into a side panel using this function: https://azuremapscodesamples.azurewebsites.net/index.html?sample=Simple%20Store%20Locator This sample is covered in detail in this tutorial: https://learn.microsoft.com/en-us/azure/azure-maps/tutorial-create-store-locator

Painting frames while media session is paused

I'm working on a custom video player using the Media Foundation framework.
Currently, I can play, pause, stop or change the rate of the playback using an IMFMediaSession.
I can also retrieve a single frame using an IMFSourceReader.
I am currently able to render a frame (IMFSample) to a window area (a HWND) but only when the media session is stopped.
My goal is to be able to render a frame while the media session is paused.
(= doing frame-stepping using a source reader and not the media session)
I'm using GetDC, CreateBitmap, SelectObject and BitBlt to render my frame.
I tried using directd3d interfaces to fill it with a solid color (I'm really new to direct3d so followed a basic tutorial) but it didn't work.
Here is what I did : retrieving an IDirect3DDeviceManager9 with MR_VIDEO_ACCELERATION_SERVICE, doing OpenDeviceHandle, LockDevice, Clear, Begin/EndScene and Present.
None of these calls fail but I suspect the EVR is still painting the last frame.
So basically, I want the EVR to stop repainting its frame when I want and of course, I need to re-enable its painting process.
Any idea how to do that ?
Thanks
I finally got it working.
If you're interested, do the following:
retrieve IMFVideoDisplayControl and IMFVideoMixerBitmap from the media session using MFGetService
set up MFVideoAlphaBitmap structure and feed it to IMFVideoMixerBitmap::SetAlphaBitmap (there is a working example at the dedicated MSDN page)
call IMFVideoDisplayControl::RepaintVideo to update the output
To hide the previous content, don't set the alpha so that it's opaque.
Call IMFVideoMixerBitmap::ClearAlphaBitmap to get the previous content back.
And voilĂ  !

Resizable MKOverlay using MKOverlayRenderer

I want to have a custom MKOverlay that's a circle anchored to the user location annotation that the user can resize by pinching. I was able to successfully achieve this using MKOverlayPathRenderer and a custom MKOverlay object by overriding the createPath method and making an arc. The resizing and moving of the overlay was handled by using KVO on the radius and coordinate properties of my overlay. However the resizing was incredibly choppy and the boundingMapRect wasn't correctly calculated.
I've also tried using an image and instead of subclassing MKOverlayPathRenderer just MKOverlayRenderer, overriding - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context but when I resize my CPU percentage jumps to 160% usage (not great yeah?) and the boundingRect is again being drawn incorrectly.
I really think the way to do it is with MKOverlayPathRenderer and maybe having an atomic counter of some kind so that a redraw only gets called say every 5 or 10 times the pinch gesture is triggered.
Does anyone have any suggestions? I've also considered but haven't tried making a UIView and adding it as a subview to the map view and putting the pinch gesture on that but that seems hacky and dirty.
When you computed new boundingMapRect on the Overlay, you must invoke invalidatePath on your Renderer. After that, system will invoke createPath for you when appropriate.

Allowing For Scrollbar When Resizing Container

I'm developing an application using GWT 2.3.0 and GXT 2.2.5.
I've got a LayoutContainer with ScrollMode set to AUTO and layout set to RowLayout with a horizontal orientation. It's used as the display window for my application.
The problem is that when the browser is resized so that the vertical scrollbar is displayed, the contents do not resize to account for it, causing the horizontal scrollbar to also appear even if it's not needed.
Is there a way to have the layout account for the space taken up by the scrollbar when rendering the widgets?
Ok that is a bit tricky to accomplise. I would do it like this:
On the Entry point (so that you know it is always active) add a resize handler to the Window
Window.addResizeHandler(new ResizeHandler() {
#Override
public void onResize(ResizeEvent event) {
// Fire Event containing the new size informing the application of the change
// Or resize the Layout container
}
}
If you choose to fire the event and you are using the MVP pattern then it is pretty simple to fire the event via the event bus and catch it wherever you like in the application.
The only catch here is that you might want to run the functions in onResize() inside a timer as in many cases the Window width/height reported have not the final value, due to the event being fired before the resizing completes.

How best to handle a portrait mode and landscape mode in a single view?

My current understanding is that I have to assign the coordinates in the code itself instead of using the interface-builder. Is there a better way to do this?
Currently I am trying to handle a login view. It works well in portrait mode but in landscape mode few of the contents are hidden. Please suggest how to handle this.
Thanks
GuruPrasad R Gujjar.
You can handle this one of two ways. The first is what you suggested and change all of their frames, and second is to just have a separate view that is in landscape mode and switch it out on rotation.
For both cases you need to implement these two methods
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation== UIInterfaceOrientationPortraitUpsideDown) {
//put the portrait orientation here
self.usernameField.frame=CGRectMake(xPortraitLocation, yPortraitLocation, xWidth, yWidth);
...
}
else{
//do the same thing with everything but for landscape mode
}
With a seperate view you just switch them out by saying self.view=self.lanscapeView or self.portraitView.
If I am going to use the first method I sometimes like to create a fake view in the interface builder so that I can put all my items in the correct locations and look under the location tab which eliminates the guess and check of assigning the numbers.
Hope this helps.

Resources