I have a list of 15k I need to display on a MKMapView embedded in my app.
I think this is probably too many to load at once, and I want to check if there is a standard way to do this. The XML file with the informations about the pins is stored on a webserver.
I think I have a few options, but still I'm not sure where the bottleneck would be (network, displaying many pins at once, loading the pins on the map the first time, etc):
Parse the whole xml file and add all the annotations. Force the user zoom so you can't see too many pins together
Parse the whole xml file and add all the annotations. Use a library for grouping the Pins.
Load only the top 50 pins in the area the user is currently in. Everytime the position is updated call a script on the webserver that only serves 50 positions based on map latitude-longitute and zooming.
Cache everything in coredata and do the same as the previous point.
Any considerations about performances I should do? Any other solutions? Will these perform well enough?
Thanks!
The bottleneck will be displaying that many pins at one time on the map. You shouldn't display more than around 500 at one time. Zoomed in might be OK, but zoomed out will affect performance and map visibility.
Here's a library that will do clustering for you:
http://applidium.com/en/news/too_many_pins_on_your_map/
Related
I'm looking to load a large quantity of data within tabulator and running into performance issues. Having only the small subset of records that are visible loaded would be ideal.
Reading through the documentation I could use progressive loading with an ajaxurl to load data as the user scrolls down the table with ajaxProgressiveLoad set to scroll.
Is there any way to discard the data that the user has scrolled past to keep the memory footprint low. This would also require the ability to reload it if they scroll upwards. Essentially a bidirectional infinite scroll.
I presume this could be implemented by modifying the existing ajax module, would appreciate any pointers in the right direction.
There is one problem: I made it using maperitive tiles with the required scale of 12-15 (so that the map is available offline), then the task was to connect the resulting offline map to this project: https://github.com/ds4es/real-time-units- gps-tracking (the project is based on transferring data using kafka from a csv file, which contains latitude ,longitude time, to a map with the leaflet plugin, to display the real-time movement of markers on the map), however, this did not work, apparently some are required - something http requests, not just a link to tiles. I want to note that a similar way of writing: file:///home/jonh/openstreetmap/{z}/{x}/{y}.png worked in another project, but unfortunately not in this situation. Attached images below
The 1st figure shows the state of affairs when adding an offline map ( line: MAP_URL_TEMPLATE=' Tiles/{z}/{x}/{y}.png) and, as we can see, only moving labels are displayed, and the map itself is not displayed;
2nd figure Shows the state of affairs when the online map is used, i.e. constantly need internet to display it;
The 3rd picture shows the console, where, before the red line, an offline map was used (Tiles/{z}/{x}/{y}.png). And after the red line, I changed the address to the online map again: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' and the map started showing up all over again.
How can I connect an offline map? Thanks for answers :)
I'm building an iPhone app (in iOS 5) with several different views, one of which contains a map (also has separate view controller). The first time I go over to this view, it takes a while for it to load, and things such as animating pin drops also don't work well as a result of it. Not to mention that it takes a bit for the location to stabilize.
What I want to know is if there's a way to load MKMapView before a user goes to that view, so by the time they get there, these issues aren't present anymore.
I've already seen this and this question but they haven't been very helpful. Keep in mind that I don't really need to interact with that view before I get there, I just want it to be fully loaded by the time I go there.
Here is the situation:
I am displaying images on the map by using custom annotations. Everything works fine but I would like to improve it visually by resizing the AnnotationView so that it shrinks as the map is zoomed out. I want to do this because, obviously, more annotations fill up the screen and need to be shrunk so that they don't overlap each other too much and the user can see more annotations. (Of course, I would like to enlarge AnnotationViews when the map is zoomed in again).
I have achieved this by removing all annotations from the map and adding them back again, whenever regionDidChangeAnimated is called. However, these images are loaded from the internet, so downloading the images again (since the annotations have been removed) doesn't seem to make sense.
I hope I have explained the situation well, and hope to contribute to SO in the future.
Thanks in advance.
P.S. I'm developing with iOS 4.0
Since you are using iOS 4.0 I would suggest using a class that conforms to the MKOverlay protocol instead of MKAnnotationView. Overlays zoom with the map and will scale appropriately. You can probably use 1 overlay to handle all your annotations. Check out the HazardMap demo Apple provided in the 2010 WWDC talks on http://developer.apple.com
Alternatively, you could use something like the k nearest neighbors algorithm to group annotations per zoom scale. However, that can be kind of slow if you have a lot of annotations. I tried it once with several thousand annotations and did not like the performance hit that was incurred. I think < 1000 annotations might have decent performance with this method though.
It sounds like you're already on the right path and that the only real problem is the downloading of the images. Is there any particular reason you can't cache them by writing them to the documents directory (or the cache directory if you want them to go way when the app quits) when you receive them and look there first before displaying them?
In my app i'm adding alot of pins and in viewForAnnotaion I set animatesDrop=TRUE on my MKPinAnnotaionView. The problem is that when having 200+ pins dropping one by one takes a long time. I have seen Apps that drops all pins at once and wonder how to do that.
Let me know if i'm not clear.
Thanks!
What you are doing is not wrong - but you might want to try creating those pins on a secondary thread (your app will be snappier).
Also, you might have operations that are computationally expensive that you might want to move outside the delegate method (i.e. viewForAnnotation).
Finally, you can try closing in on a smaller area, so that your map displays less pins.
I think it is done programmatically by detecting that pins are closest.
You could build differents list of pins depending on the map zoom to display only pins that are separates of x pixels on the screen.