Git Product home page Git Product logo

google-maps's Introduction

Build Status NuGet Status

google-maps

Google Maps Web Services API wrapper for .NET

For Quickstart and more info read the wiki pages (https://github.com/maximn/google-maps/wiki)

The web page - http://maximn.github.com/google-maps

NuGet page - https://www.nuget.org/packages/GoogleMapsApi/

Check out my blog at http://maxondev.com

Quickstart

This library wraps Google maps API.

You can easily query Google maps for Geocoding, Directions, Elevation, and Places.

NEW! Now you can easily show the results on a Static Google Map!

This Library is well documented and easy to use.

Code sample -

	//Static class use (Directions) (Can be made from static/instance class)
	DirectionsRequest directionsRequest = new DirectionsRequest()
	{
			Origin = "NYC, 5th and 39",
			Destination = "Philladephia, Chesnut and Wallnut",
	};

	DirectionsResponse directions = MapsAPI.GetDirections(directionsRequest);

	Console.WriteLine(directions);


	//Instance class use (Geocode)  (Can be made from static/instance class)
	GeocodingRequest geocodeRequest = new GeocodingRequest()
	{
			Address = "new york city",
	};

	GeocodingEngine geocodingEngine = new GeocodingEngine();

	GeocodingResponse geocode = geocodingEngine.GetGeocode(geocodeRequest);

	Console.WriteLine(geocode);


	// Static maps API - get static map of with the path of the directions request
	StaticMapsEngine staticMapGenerator = new StaticMapsEngine();

	//Path from previos directions request
	IEnumerable<Step> steps = directions.Routes.First().Legs.First().Steps;
	// All start locations
	IList<ILocation> path = steps.Select(step => step.StartLocation).ToList<ILocation>();
	// also the end location of the last step
	path.Add(steps.Last().EndLocation);

	string url = staticMapGenerator.GenerateStaticMapURL(new StaticMapRequest(new Location(40.38742, -74.55366), 9, new ImageSize(800, 400))
	{
			Pathes = new List<Path>(){ new Path()
			{
					Style = new PathStyle()
					{
							Color = "red"
					},
					Locations = path
			}}


	});

	Console.WriteLine("Map with path: " + url);



	//Instance class - Async! (Elevation)
	ElevationRequest elevationRequest = new ElevationRequest()
	{
			Locations = new Location[] { new Location(54, 78) },
	};

	ElevationEngine elevationEngine = new ElevationEngine();

	elevationEngine.BeginGetElevation(elevationRequest,
											ar =>
											{
													ElevationResponse elevation = elevationEngine.EndGetElevation(ar);
													Console.WriteLine(elevation);
											},
											null);

	Console.WriteLine("Finised! (But wait .. async elevation request should get response soon)");
	
	

google-maps's People

Contributors

maximn avatar allon-guralnek avatar tystol avatar petelopez avatar genbox avatar george-shaw avatar graham128 avatar gaslitbytech avatar donlockhart avatar idisposable avatar sevagd avatar kevbite avatar lucasjans avatar

Watchers

Cristi Badila avatar James Cloos avatar  avatar

Forkers

agilefreaks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.