Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Library for Google Maps API support

I'm looking for a .NET library or wrapper for Google Maps, that contains all the types of responses as C# classes.

I want to be able to do something like:

var url = "http://maps.googleapis.com/maps/api/geocode/json?address=Wellington&sensor=false";

//Utility functions would be ideal                  
string jsonResponse = GoogleMaps.GetJson(url);
string jsonResponse = GoogleMaps.GeocodeAddress("Wellington");

I would like to be able to use the results like:

GeocodeResponse r = JsonConvert.DeserializeObject<GeocodeResponse>(jsonResponse);    //I am using Json.NET

if(r.status.Equals("OK"))
{
    DoSomethingWith(r.result.formatted_address);    //intellisense documentation for all the bits in the result would be great
}

Does such a thing exist?

This is sort of like these questions:

  • which is the best .net library for google maps api?

  • Best .NET Wrapper for Google Maps or Yahoo Maps?

However the answers there are not what I am meaning, I'm not looking for a drag and drop map control.

like image 930
elwyn Avatar asked Mar 13 '11 07:03

elwyn


People also ask

Which API is needed for Google Maps?

A web page or application displays a map using the Maps JavaScript API.

Is gmap API free?

As mentioned, you won't be charged for your Google Maps API usage until you turn on auto-billing. The free trial limits you to $300 in credit over 90 days. API users also get $200 of credit per month toward API requests, equal to 100,000 static map requests or around 28,000 dynamic map requests per month.


2 Answers

This API is still in development but may provide you with what you are looking for:

http://code.google.com/p/gmaps-api-net/

like image 174
codingbadger Avatar answered Sep 20 '22 23:09

codingbadger


.NET wrapper libraries for the Google Maps API :

  1. GoogleApi
  2. google-maps

gmaps-api-net is outdated (at this time of answering) - the last update for the Directions API was made in 2016.

Usage example for GoogleApi:

using GoogleApi.Entities.Common;
using GoogleApi.Entities.Maps.Directions.Request;
using GoogleApi.Entities.Maps.Directions.Response;

public void GetRoute()
{
    DirectionsRequest request = new DirectionsRequest();    

    request.Key = "AIzaSyAJgBs8LYok3rt15rZUg4aUxYIAYyFzNcw";

    request.Origin = new Location("Brasov");
    request.Destination = new Location("Merghindeal");

    var response = GoogleApi.GoogleMaps.Directions.Query(request);

    Console.WriteLine(response.Routes.First().Legs.First().DurationInTraffic);
    Console.WriteLine(response.Routes.First().Legs.First().Distance);
    Console.WriteLine(response.Routes.First().Legs.First().Steps);
}
like image 28
Alex Pandrea Avatar answered Sep 19 '22 23:09

Alex Pandrea