-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add StaticMapsEngine.GenerateStaticMapURL accept encode path
#159
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
[![Build Status](https://github.com/maximn/google-maps/actions/workflows/dotnet.yml/badge.svg)](https://github.com/maximn/google-maps/actions/workflows/dotnet.yml) | ||
[![NuGet Status](https://img.shields.io/nuget/v/GoogleMapsApi.svg)](https://www.nuget.org/packages/GoogleMapsApi/) | ||
|
||
google-maps | ||
=========== | ||
# google-maps | ||
|
||
Google Maps Web Services API wrapper for .NET | ||
|
||
|
@@ -12,7 +11,6 @@ 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 | ||
|
@@ -26,7 +24,8 @@ NEW! Now you can easily show the results on a Static Google Map! | |
This Library is well documented and easy to use. | ||
|
||
Code sample - | ||
``` C# | ||
|
||
```C# | ||
using GoogleMapsApi; | ||
using GoogleMapsApi.Entities.Common; | ||
using GoogleMapsApi.Entities.Directions.Request; | ||
|
@@ -36,23 +35,28 @@ using GoogleMapsApi.Entities.Geocoding.Response; | |
using GoogleMapsApi.StaticMaps; | ||
using GoogleMapsApi.StaticMaps.Entities; | ||
|
||
var googleAPIKey = "google api key"; | ||
//Static class use (Directions) (Can be made from static/instance class) | ||
DirectionsRequest directionsRequest = new DirectionsRequest() | ||
var directionsRequest = new DirectionsRequest() | ||
{ | ||
Origin = "NYC, 5th and 39", | ||
Destination = "Philladephia, Chesnut and Wallnut", | ||
IsSSL = true, | ||
ApiKey = googleAPIKey, | ||
}; | ||
|
||
DirectionsResponse directions = GoogleMaps.Directions.Query(directionsRequest); | ||
var directions = await GoogleMaps.Directions.QueryAsync(directionsRequest); | ||
Console.WriteLine(directions); | ||
|
||
//Instance class use (Geocode) (Can be made from static/instance class) | ||
GeocodingRequest geocodeRequest = new GeocodingRequest() | ||
var geocodeRequest = new GeocodingRequest() | ||
{ | ||
Address = "new york city", | ||
Address = "NYC, 5th and 39", | ||
IsSSL = true, | ||
ApiKey = googleAPIKey, | ||
}; | ||
var geocodingEngine = GoogleMaps.Geocode; | ||
GeocodingResponse geocode = geocodingEngine.Query(geocodeRequest); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this should be part of this commit? Seems like unrelated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
var geocode = await geocodingEngine.QueryAsync(geocodeRequest); | ||
Console.WriteLine(geocode); | ||
|
||
// Static maps API - get static map of with the path of the directions request | ||
|
@@ -75,6 +79,29 @@ string url = staticMapGenerator.GenerateStaticMapURL(new StaticMapRequest(new Lo | |
}, | ||
Locations = path | ||
}} | ||
, | ||
IsSSL = true | ||
, | ||
ApiKey = googleAPIKey | ||
}); | ||
Console.WriteLine("Map with path: " + url); | ||
|
||
//use EncodePath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need this comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
var overviewEncodePath = directions.Routes.First().OverviewPath.GetRawPointsData(); | ||
string encodePathUrl = staticMapGenerator.GenerateStaticMapURL(new StaticMapRequest(new Location(40.38742, -74.55366), 9, new ImageSize(800, 400)) | ||
{ | ||
Pathes = new List<GoogleMapsApi.StaticMaps.Entities.Path>(){ new GoogleMapsApi.StaticMaps.Entities.Path() | ||
{ | ||
Style = new PathStyle() | ||
{ | ||
Color = "red" | ||
}, | ||
EncodePolyline = overviewEncodePath | ||
}} | ||
, | ||
IsSSL = true | ||
, | ||
ApiKey = googleAPIKey | ||
}); | ||
Console.WriteLine("Map with EncodePath: " + encodePathUrl); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intentional? If not, please revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visual Studio automatically formatting it.
Could you tell me how to revert?