How to add pins to map? - c#

So I am creating an app which will have map with pre added locations (pins) into it and when user comes near that location (s)he will get notification. My problem is, how to add Pins into Xamarin Maps? I am not using Google Maps, I am trying to do with "Xamarin Custom Map?".
I have opened map, but it is opening in Google Maps appliation. I looked for a way not to use Google Maps Api, but I didn't find a single solution how to do this without Google Maps, so is it even possible?
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 20;
var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(20), null, true);
Map.OpenAsync(position.Latitude, position.Longitude);
This code here opens map application on my smartphone (in this case GoogleMaps), so I am wondering is it possible to add pins to it, or somehow open map inside of my app wihtout using Google Maps API?

thx all for feedback, using Google Maps API is easiest and best solution for this! :-)

Related

Call Google Directions API form Xamarin.Forms app

I'm trying to set up a basic app to call the Google Directions API from a Xamarin.Forms app in Android. I'm new to Xamarin & C# generally, so have struggled searching for the right terms, but am familiar with the directions service from a javascript angle.
I'm using this basic app as a test bed: https://learn.microsoft.com/en-us/xamarin/android/platform/maps-and-location/maps/maps-api
I can add the button and associate a process with it, but how do i call the API & catch the results?
I'll worry about plotting etc later, i just want to write out the results to console for now.
Thanks for your help in advance!
1.First of all, you can used following URL to get Json data.(Please notice:You need to enable the Directions API in Google console,otherwise, you will get error message This API project is not authorized to use this API.)
https://maps.googleapis.com/maps/api/directions/json?origin=lat1,lon1&destination=lat2,lon2&key=yourApiKey
In this URL, you need to provide the latitude and longitude of Origin position and destination postion.API key(You can get the API key from a Google console)
2.You can play and just change variables in this link and open it in browser, to see the returning object like this screenshot.
3.When you receive the return object, you will need to parse it.(Prase json data:http://bsubramanyamraju.blogspot.com/2017/04/xamarinforms-consuming-rest-webserivce_17.html)
4.The distance will be at googleApiRouteObject.routes[0].legs[0].distance; There you will find a int representation in meeters, and string representation like 2km.
5.The waypoints will be coded in Polylines, you will need to parse them. You can find how to do that with code examples here: https://developers.google.com/maps/documentation/utilities/polylineutility
If you want to get the sample code, you can refer to this link.
https://agileapp.co/xamarin-forms-maps-polyline-route-highlighted-google-api

Finding likely locations in Xamarin using google maps API

I am working on a Xamarin iOS project trying to display a list of the most likely locations based on the user's GPS coordinates using either the Place Picker or GMSPlacePickerViewController from the google maps API, as shown in this Swift tutorial.
However I can't seem to find any decent tutorials using C#. I don't want to display the map to users I simply want to retrieve the list of most likely locations based on the coordinates.
Any guidance would be greatly appreciated as I'm at a bit of a loss about how to use the google maps API to achieve this.
Okay answering this for anyone coming after me and trying to do something similar.After lots of searching I have realised it is possible to use the nearbySearch method from the Google Places API Web Service to retrieve a list of addresses near particular coordinates within a specific radius (in metres). You can optionally specify the type of addresses you are searching for, e.g. Restaurants.
Not sure how I missed this but there is a Place Search demo at the bottom of this page;
https://developers.google.com/places/web-service/

Create Custom Public Google Map with Markers

I have a discord bot written in c# that reports events based on their latitude/longitude. I want to take the latitude/longitude data and place markers on an html based google map (locally hosted or online) using c#
Can someone point me in the right direction?
You'll want to use the Google Static Maps API.

Conversion of Google Map webpart into Bing Map webpart

here is the Google version
I did almost 2 days research to find something like this for Bing Maps, but no luck, Now I am looking to change this Google Map project into Bing Map project, I have no Clue.
Can someone Explain the code of this project and the changes I need to make it Pick up Bing Maps.
I know I need to Change GoogleMap.js to BingMap.js, I can get this script from Bing SDK, but i can't figure out what else changes i will have to make.
Here is the Bing Map Project, but its getting Image of Map and not actually using Maps API
Find what I wanted, and here is the Link,
enter link description here
and thanks People for your Negative Comments !
One thing I would like to mention that, I went through Apress Book "Sharepoint 2010 as development platform" which shows you how to deploy a bing map as webpart but they missed the most Important bit, In there Code (got from there website) they are not registering the script using "ClientScriptManager" which is breaking javascript and when you use that webpart it doesn't let you use the ribbon Controls, So if anyone had issues (as i seen many posts people having same problem) Just add the following before your java script (for sharepoint 2010 webparts)
System.Web.UI.ClientScriptManager csm = Page.ClientScript;
StringBuilder builder = new StringBuilder();
string SCRIPT_NAME = "MapScript" + this.ID;
{// your java script}
csm.RegisterClientScriptBlock(this.GetType(), SCRIPT_NAME, builder.ToString(), false);
If I said anything wrong please correct me, Cheers (and if my answer helped you rate it :))

Offline Maps by Longitude Altitude?

I'm trying to create a C# application that downloads maps from some Maps Database (OpenStreetMap, Google Maps, Yahoo Maps)
And then to make an API that show me my location on the downloaded maps without being connected to the internet ...?
I found a lot of examples of google offline maps but i cant find something to show your location on downloaded maps using Longitude and Latitude.
As far as i know the GMap.Net control can use a local cache. So you could populate the cache with the tiles you like and afterwards simply change to cache-only mode.
If you look deeper into code it should also be possible to get some data in and out of the cache by some API. So you could download the tiles once and save them to disk. At startup you'll inject the tiles into the cache and set the mode from the beginning to cache-only.

Categories