This utility uses the Maps JavaScript API. Specifically,
encoding and decoding of paths are handled by the static methods encodePath()
and decodePath
in the google.maps.geometry.encoding
namespace.
See the Encoded Polyline Algorithm
Format for information about the encoding scheme.
Google Maps generates a simple polyline from two or more latitude/longitude coordinates. Learn more about simple polylines and complex polylines in the JavaScript API documentation.
Click this interactive map to add polyline coordinates. Use the results to obtain an encoded polyline for use in your application.
- Click on the map to place the first location of your polyline. You can drag the marker to adjust the location.
- Click the Add Location button to add the location to the Locations list.
- Repeat for each location on your polyline.
- The polyline encoding appears in the Encoded Polyline
- Click the Delete All Locations button to clear the Locations list before decoding a new polyline.