iPhone Xcode PDF MAP location GPS - ios

I have a PDF map. What's the easiest way, to add a GPS "blue dot" with my location. Somehow to sync it with maps & add this PDF as a layer on top of that? Thanks

Here's a post on rendering a PDF to PNG. How to convert PDF to PNG efficiently?
You'll need to know the GPS coordinates at the top left and bottom right of the image that produces.
You can try creating an MKOverlay containing the image and define its MKMapRect based on those known coordinates.
If that doesn't work for some reason, you could use MKMapView's convert(_:toPointTo:) to tell you where those GPS coordinates are on a UIView that you manage yourself. (Heads up: that's more complicated than it seems)

Related

Prevent GMSMarkers from Scaling on iOS?

I am using GMSMarkers on iOS with the Google Maps API. I have a GMSMarker with a PNG image and no matter my zoom level on the map view the GMSMarker keeps its size respective to the screen. If I zoom in it is 30 points across the screen, and if I am zoomed all the way out on the map it is still 30 points. I do NOT want this to happen, I want the GMSMarker to stay small no matter what the zoom level is. It would be preferable that I do not have to loop through all my GMSMarkers every time the camera zoom changes, as I will be eventually having 50-100 of them on the map.
Is there anyway to keep the GMSMarker small no matter the zoom level on the GMSMapView?
I am using Objective-C, but if someone can only give me help in Swift or even Java I can still make do with that.
You could use a GMSGroundOverlay to add an image to the map which scales along with the map. So instead of a fixed size in pixels like a GMSMarker, it stays a fixed size in metres.
Note that another difference is that a ground overlay also stays oriented with the map, ie if the map is rotated/tilted, the top of the image rotates to point north, instead of staying pointing to the top of the screen like a marker.

mbtiles: Is it possible to draw some lines on offline mbtiles map

I have an .mbtiles file and I am using it for offline map (iOS MapBox SDK). But my .mbtiles doesn't have enough data (just simple green rectangle). I want to draw some lines(roads) between points (I download it from my rest API). I found the solution to use RMShape, but I want to use already drawn map. I create my .mbtiles from osm and TileMill. Help me out please.
WhirlyGlobe-Maply SDK can help you achieve this.
It has a mapview and a globe view which you implement on your viewcontroller.
Then you create a layer using your mbtile file as shown below:
let tileSource = MaplyMBTileSource(mbTiles: "your-mbtile-filename")
You add this layer on the globe or map to display the tiles.
And using SDK's function like addShapes(), you can add, circles, vectors, labels, text and icons on the map/globe.
I tried adding lat and long lines programatically. Also tried adding some labels and spheres.
This is how it looks ->
WhirlyGlobe-Maply using mbtile and drawing on top of it

How to show indoor annotations on MKMapView

I need to show an indoor floor plan in a MKMapView. So far I have managed to load custom map tiles into MKMapView. But when I try to show annotations it does not show in correct location. The space between latitudes are not equal. I think it’s because MKMapView maps the globe into flat surface. But in my case I need to show annotations in a flat surface. Any idea how to do this?
EDIT : Anyone know how to convert geographic coordinates to cartesian coordinates? That will solve this problem
Apple just updated its demo project:
https://developer.apple.com/library/prerelease/ios/samplecode/footprint/Introduction/Intro.html
Take a look, there are information about how to translate geolocation (spherical) to flat location.

Draw a grid onto an MKMapView

I'd like to draw a grid into my map, that represents the size of a tile at a certain zoom level. So for example I'd like to have a grid on my mapview that shows the outline of a zoom level 10 tile. So the outline of where this tile would be. No matter if the mapview itself is at zoom level 5 or 15, it should display the outline of where that tile would be placed.
The problem I have is how to calculate the proper rect that represents each visible "tile".
Any help is sooo much appreciated!!!
Or maybe the answer to following question would help:
How can I convert a MKMapRect to a MKTileOverlayPath?
I find that MapKit is way too limited when you want to start doing more and more with maps.
I would reccomend using Google Maps SDK for iOS: https://developers.google.com/maps/documentation/ios/start
and then using GMSTileLayer for the tiles:
https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_tile_layer
In the long run, replacing MapKit with Google maps gives you far more features and options and has better geolocation and reverse geolocation than Apple
You can also look at Mapbox. Between using TileMill to create a grid layer by setting the Map background to a pattern image, you could then only export zoom level 10 and either host it on Mapbox or export it to MBTiles format (SQLite-based). Then one of the Mapbox mobile toolkits could serve the tiles out as an overlay on your map.

iOS using GPS show the blue dot on an image?

How do I make a image, make it georeferenced and make it such that using the GPS, a blue dot appears where I am standing (assuming the image is there) in my iOS application. How do I approach this to georeference my image and accomplish this?
The only way to do this would be to use MKMapView. There is a property you can set, -showsUserLocation, that will show the blue dot you need.
If you need to show this over the top of a specific image... you will have to get creative with it. Maybe loading a custom image for an annotation. It can be done, just depends on how big of a map you plan to show and what your use case is. Hope this helps.
The steps I would take are as follows :
Get the user's location using a location manager
Capture the image
Instead of saving it to the disk, copy the image to a new file named something like "imageprefix_(user location's latitude value)_(user location's longitude value).png"
Put an MKMapView in your UIViewController and set
[viewController.mapView showsUserLocation:YES]
Show the image below, or above. In the future, if you're not at that location, use the latitude and longitude values from the title of the image to drop an annotation on your mapView
Good luck!

Resources