I am building a simple app where user can draw freehand on Google map and select markers within it. I am using Xamarin Forms to build this application.
I have tried few things to draw freehand on Google Map, but on mobile screen inside webview it does not work.
So, I used a Xamarin plugin to generate Google map in screen, but this plugin https://github.com/amay077/Xamarin.Forms.GoogleMaps
Does not have freehand drawing too but it has a polylines drawing tool with given positions.
My idea was that if I could overlap a layer on screen and use darw freehand on that layer and convert those points of screen into Maps Lat and Lon, then can pass these Lat/Lon to Map plugin to draw polyline right on map for me.
For drawing on map I am using another plugin of Xamarin forms SkiaSharp, and I have made its background transparent, so, it gives a look like we are just making drawing on directly Map.
So, till here all is perfect, also I have got Lat/Lon of all sides of Map too.
So, I have
- SkiaSharp on screen overlayered on Google map which makes drawing on that layer perfect, and map is fully visible in background to give a look like we are drawing on Map
- I have Lat/Lon of all four sides of Map (Top, Left, Right, Bottom)
- I have points when drawing on SkiaSharp screen
the problem is that I do not know how to convert
The solution I have found here all are related to either only android or web based google maps api,
I need some idea how can I convert my screen points into Google Lat/Lon
I have few ideas but not sure how they will work
Maybe we can use xamarin.forms.maps, and build some middleware to communicate between screen points and xamarin.forms.maps to get coordinates, this might be helpful in case of iOS as well, so, we will get coordinates using default Maps, and pass those coordinates to Google maps plugin to create polylines on map
Maybe a server based API to which we pass screen size, points, maps 4 sides coordinates and that API can return us Lat/Lon against them?
Or some formula inside app to convert X,Y points to Coordinates?