Google Maps iOS SDK: GMSPolyline & GMSMarker Performance Issue - ios

I couldn't find any Google Maps SDK best practices on the inter-webs so I'm asking here. I'm working on an app with a large number of GMSMarkers (200+) and GMSPolylines (9000+). When I load all of them the map scrolling & zooming becomes laggy (kinda expecting that). Can someone tell me what's the best approach to this problem? Should I...
Calculate the markers and lines within the current bounds and only show those?
and recalculate on scrolling?
what if the user zooms all the way out, it would still load everything?
Is many two-point line segment polylines more performant or a handful of long complicated polylines?
Thanks!

you should find strategies NOT to add everything all the time.
only have that on the map that you can see.
That means: recalculate on bounds change but also: even if zoomed all the way you shouldn't need to display everything at once

Related

Achieving equal size of square/pixel on Mapbox anywhere on the world map?

The problem I'm facing is similar and closely related to this issue on Github but that's for Unity SDK, my question is for iOS SDK.
I want to achieve the same thing. Let me explain, basically I have pixel grid in which each pixel'd have equal size. Pixel is set to be 10m x 10m in real world. The thing I experienced is that if pixel locates towards the northern or southern part of the world, its size is stretched like the following.
Click for larger resolution
But when such pixel locates along the equator line, or simply along the middle part of the world. It looks ok like following
Click for larger resolution
There's no problem about rendering stuff, or positioning on Mapbox. The thing is I want every pixel to be square visually.
I've read along on the issue I linked above. It relates to mercator and the world is not flat thus makes this visual happens. It looks stretched along the northern and southern part of world map. As well, I found out that there's no equal functionalities as presented in Unity SDK for this particular problem on iOS SDK, so I'm not sure which approach I should go on to solve this solution.
How can I achieve equal size of pixel on the gridline on mapbox using Mapbox iOS SDK? Is there already solutions provided in the SDK?
FYI.
My requirement also needs real distance as shown on the map. I'm not sure it'd affect the solution as presented in the link I linked above.
I use Mapbox iOS SDK 3.7.6
My initial approach is straightforward as I fix the size of pixel to be 10m x 10m, then calculate its corresponding latitude and longitude value. Use those values to position them in Mapbox treating entire world map as a tilemap. Anyway I didn't take into account mercator in calculation, so this might be the case, if so then how to do just that? Only thing from my checking as available in iOS SDK is MGLMapView's metersPerPoint(atLatitude:). No tile ID system, or Conversions.cs as seen on Unity SDK. So i'm not sure on how to go on and solve this problem.
Update
I managed to solve it and made it work!
I'll come back and post the solution.
My solution is to port sphericalmercator.js to swift, then use it in code. I use a fixed zoom level of level 22 as its visual look is closest to what I need and also before. I went with the approach to at least have it looks visually equal not necessary its physical size.
Thanks to a hint in this answer on how to use sphericalmercator.js.
Anyway from my testing with it, tile size as set when you creating an instance using SphericalMercator seems not to be in effect no matter what value I set. Only zoom level will determine number of tiles across the world map for you. Note that upper-left corner is origin which is 0,0 tile index. Lower zoom level value will generate large tile size, but higher value will generate smaller tile size.
You can take a look as SphericalMercator-swift; the code I ported from origin JS implementation as linked above along with how to use it to get tile index, or bounding box of longitude/latitude in swift code in order to do rendering stuff on top of Mapbox.

ARToolkit Multiple Mandatory Markers

I studied the multimarker documentation of ARToolKit for iOS and i have some troubles in achieving some sort of QR-Code.
I want, for example:
A set of 6 markers positioned differently on a picture, and when and only when ALL of them are present, some sort of video is displayed in the origin of them( i want to use some sort of CORNER Markers like QR-Code system ).
How to do this ? From what i've seen, on multimarkers, if 1 is present out of 6 for example, the object is displayed.
From looking into the ARToolKit code you can see that a MultiMarker is internally handled as one single Marker consisting of several Pattern:
https://github.com/artoolkit/artoolkit5/blob/master/lib/SRC/ARWrapper/ARMarker.cpp#L344
https://github.com/artoolkit/artoolkit5/blob/master/lib/SRC/ARWrapper/ARMarkerMulti.cpp#L75
That is why ARToolKit will always return true whenever one of the markers configured in the multi-marker configuration is visible.
Taking that into account ‘Multi-Markers’ are not the way to go for the target you would like to reach.
What you can do, however, is to configure each marker separately and add them as ‘Single-Marker’. Then you can query if all of these ‘Single-Markers’ are visible.
If so you can calculate the origin of all these ‘Single-Markers’ and render your object there.
You can get an idea on how to configure several ‘Single-Markers’ if you take a look here:
http://augmentmy.world/moving-cars-augmented-reality
Also take that example here on how to set to markers into the same coordinate system (and calculate the distance between them) you can use that as a starting point for calculating the origin between several markers:
https://github.com/artoolkit/artoolkit5/tree/master/AndroidStudioProjects/ARMarkerDistanceProj
I know that these are not iOS examples but I have only done Android so far. Also, the ARWrapper interface should be the same on Android and iOS, meaning to say there should not be much difference between these two.
I hope that helps

Positioning of location markers on top of location?

I followed the above tutorial (link) to make a sample app which will show markers depending upon the location coordinates for the objects(like a building) .I'm able to show my custom markers on the given location .But markers are floating around the location.How can fix my marker to show on the top of the building .?
Any suggestion or advice...
Thanks in advance!!!!!!
Your problem is most likely due to sensor jitter. Gyroscopes usually don't provide an stable reading.
I suggest you do a rolling average of the values and also add thresholds for minimum variation.

iOS how can I make MapKit display custom indoor map?

I'm trying to create a map of the office I'm working at. I have a high resolution image, and would like to autorotate it in the direction the user is heading, allowing the user to navigate around the map. I thought this could be accomplished using CoreMotion/CoreLocation and a UIScrollView, but this seems like there's some work involved.
So I'm wondering if there are easier solutions for combining a custom map and direction/position on that map - can MapKit handle this for me? Are there other frameworks that can help me show a local 2D map with compass orientation on it?
You can convert your high-res image into map tiles easily with TileMill.
You should use some custom tiles with MKTileOverlay which only display at a very high zoom level (like z 18 or whatever). I suggest you take a look over at NSHipster and read what they have about it:
http://nshipster.com/mktileoverlay-mkmapsnapshotter-mkdirections/
*Disclaimer: I haven't tried this myself, came across the NSHipster article while searching for solutions to my own problems.

Subclassing MKMapView to provide custom maps?

I'd like to provide custom navigation maps in my iOS 6 application. I've tried adding overlay views that shows these custom maps in MKMapView and it didn't work well because it needs a higher zoom level than what Apple's component can provide (the desired zoom level is about 10 screen points per meter in the map).
The question is, is subclassing MKMapView a good way to approach to this? The primary reason is I'd like to take advantage of MKMapView's coordinate conversion functions:
convertCoordinate:toPointToView:
convertPoint:toCoordinateFromView:
convertRegion:toRectToView:
convertRect:toRegionFromView:
Those functions makes it easy to convert screen points to world coordinates (latitude/longitude) and vice-versa.
Thanks in advance!
I don't think you are going to have much luck with subclassing MKMapView. There is a lot going on behind the scenes related to tile loading that you cannot access.
I would guess you would be better served using something along the lines of the MapBox iOS SDK or another similar map engine.
It allows you to specify your own tile sources and has plenty of examples to show you how it is done. It also had functions, like map kit, to handle converting values to and from lat/lon.

Resources