googlemaps / google-maps-services-go

Go client library for Google Maps API Web Services
https://pkg.go.dev/googlemaps.github.io/maps
Apache License 2.0
737 stars 214 forks source link

Improve HTML Instructions field in Step type #252

Closed torlarse closed 3 years ago

torlarse commented 3 years ago

Is your feature request related to a problem? Please describe. In this library, the Step type

// Step represents a single step of a leg.
type Step struct {
    // HTMLInstructions contains formatted instructions for this step, presented as an
    // HTML text string.
    HTMLInstructions string `json:"html_instructions"`
...
}

uses html_instructions as the JSON property key. The Google Maps Javascript API uses instructions as the JSON key for the same property. Therefore, when sending a google.maps.DirectionsLeg or google.maps.DirectionsStep from a JS client over HTTP, the HTML instructions are empty after decoding.

Describe the solution you'd like An interface (?) handling both json:"html_instructions" and json:"instructions" as equivalent keys for decoding the HTML instructions property to the appropriate field in the Step struct type.

Describe alternatives you've considered Writing a custom struct for decoding a Leg sent via HTTP. Did not succeed.

torlarse commented 3 years ago

Closing due to misunderstanding on my behalf. I realize the Go Maps types are set up to receive values from the Google Maps Platform, that is with URL requests to the API. The platform responses are not the same as the Maps JS API responses.