Drawing a circle on MapView with specifiec radius on Monondroid - xamarin.android

I'm trying to draw a circle with specific radius in km (for example 2km) on a MapView at specific lat/lng. I've found some samples:
Creating Custom Overlay on the map
Draw A Circle On Android MapView
Draw circle of certain radius on map view in android
I think first and second of above are useful but these are in Java and I need code for Mono for Android (Monodevelop).
I can't find Projection class in monodroid.
And can't use com.google.android.maps.Projection.
Can somebody help me how to use these codes in monodroid?

com.google.android.maps.Projection is an interface, so it is made available in Mono for Android as Android.GoogleMaps.IProjection to keep with normal C# conventions.
Similarly, where you'd use mapView.getProjection() in Java, in C# it is made available via the Projection property on MapView.
Xamarin has some tutorials on their site that go over how to use these to create custom overlays, so I'd suggest checking them out.

Related

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

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 MKMapView sidewalk

Im working with Mapkit and I trying to draw a line in the "sidewalks" (border of the street),right now I'm looking for ideas on how I could start this task, thanks for your help.
notes: I know how to works with mkpolyline and coordinates
http://s30.postimg.org/7rnmdjzu9/mapa.png
You do not have access to the information that qualifies as a road inside the MKMapView. so, in order to be able to draw into the border of the street you will need to access the information that qualifies as a street (the coordinates of the road) or analyzing the view and changing the specific color represented by the border of the street (this is not public API, you will need to dig around the view hierarchy).

How to put my own map in MKMapView

I need create an app for iOS using the GPS and MapKit. The idea is create my own map of my house for example and add it to the UIView or MKMapView and see the current position into the map.
see the image
You can use custom overlay on the map. Here is nice example of image overlay on the mapView.
Apple has provided sample code to do this with map tiles. Using the MapKnitter website you can geoposition your floor plan and export it in a format that Apple's code will accept.

How can I implement the custom drawing search tool used in the Realtor iPad app?

The Realtor iPad app has done a very good job of implementing a custom drawing tool on top of mapkit that they use to query an area for homes. I am familiar with mapkit and its associated classes but I am unaware of how I could do some custom drawing with my finger and have it translate to a geospatial query. How to do it?
I'm not sure how far along you've made it with this, but your basic algorithm should look like this:
Draw a polygon overtop your map, then translate the coordinates of that polygon to "map" coordinates. In order to do that you would probably need to listen for gestures on a view other than the MKMapKit instance. With my limited knowledge of the MapKit's touch event handling you might have to overlay a different transparent view on the map when you want to draw, so touch events won't go through to the MapKit (if that makes any sense). You use your finger to pinch, zoom, pan and you won't want that functionality if you're trying to draw. In that view, you'll draw the shape tracing the user's finger, then translate the points drawn into map points.
The docs indicate that you can translate screen points to map points using the convertPoint:toCoordinateFromView: method on MKMapView.
Check this link for information on that: Trouble converting MapKit user coordinates to screen coordinates
This post provides a link that might help you with drawing the polygon:
To draw polygon on google map with MapKit framework
After you've drawn your polygon you'll want to "spatially" query your data. You could do that in several ways. Locally on the device or through a web service are two options. If your data is local to the device you'll have to do the cartographic math on your device. You'll also need to ensure that your point data (the X,Y's) are in the same projection and coordinate space as your polygon's information. Polygon intersection math is relatively straight forward to do, when your projections and coordinate systems line up.
Here's a link that can help you with the math.
https://math.stackexchange.com/questions/237/how-do-you-determine-if-a-point-sits-inside-a-polygon
Alternatively you could set up some web service that takes your polygon data and performs the same cartographic math on a server and returns the results to the device. Either way the same math needs to be performed. You'll take that polygon data and determine which records in your data intersect with that polygon.
This is pretty high-level, I know, but it should be all you need to do.
Another consideration is if your data is spatially enabled with spatialite compiled for SQLite on your device or SQL Server Spatial on your server. You should be able to query the data using that polygon data. You would have to format the query properly, though.
Lastly, I would encourage you to look into the ESRI SDK for iOS. ESRI provides drawing and sketching tools out of the box. Its not too difficult to use but one downside is that you would have to learn a new API:
http://resources.arcgis.com/en/communities/runtime-ios-sdk/

Resources