How to get the shape of the road provided by PlaceId

If I have a PlaceId that represents a road, how can I get the shape of the road to highlight it on the map? The Places API returns only one location in the geometry field for roads.

For example, if you set PlaceID: ChIJ8R8rpjCuEmsRKxCMhhWn9Kg I get the following response. Note that the type field has a value of "route", but the geometry field provides only one location instead of a path.

{ "html_attributions" : [], "result" : { "address_components" : [ { "long_name" : "Darling Dr", "short_name" : "Darling Dr", "types" : [ "route" ] }, { "long_name" : "Sydney", "short_name" : "Sydney", "types" : [ "locality", "political" ] }, { "long_name" : "New South Wales", "short_name" : "NSW", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Australia", "short_name" : "AU", "types" : [ "country", "political" ] }, { "long_name" : "2000", "short_name" : "2000", "types" : [ "postal_code" ] } ], "adr_address" : "\u003cspan class=\"street-address\"\u003eDarling Dr\u003c/span\u003e, \u003cspan class=\"locality\"\u003eSydney\u003c/span\u003e \u003cspan class=\"region\"\u003eNSW\u003c/span\u003e \u003cspan class=\"postal-code\"\u003e2000\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eAustralia\u003c/span\u003e", "formatted_address" : "Darling Dr, Sydney NSW 2000, Australia", "geometry" : { "location" : { "lat" : -33.8718136, "lng" : 151.1984465 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png", "id" : "82a04f4f0548a2e7c467b71ed9c2a3a1615dac50", "name" : "Darling Dr", "place_id" : "ChIJ8R8rpjCuEmsRKxCMhhWn9Kg", "reference" : "CpQBhAAAAA4dsRcdqFcTxsVmwWs1ZWWSg9XdclQgRHhLYT2XJwEIU8BOXoS3D4cM58oNhcND-bJU7k7nmLvgHZFep405LokQpkTu0yUPQtrrgNonLRVPdLy4j9Z0M7iBpmGkPN6BuDntYu6JG9urfnIJZRdIvpibFI9QxzP7uheEnJQtI7S8Aoxth99pVl5OvyySDSfn5hIQ4Nf4YLpRjiuY34ND9qvTyBoUr24qn9M1aFa6GoO46wrfW2a12DA", "scope" : "GOOGLE", "types" : [ "route" ], "url" : "https://maps.google.com/maps/place?q=Darling+Dr,+Sydney+NSW+2000,+Australia&ftid=0x6b12ae30a62b1ff1:0xa8f4a715868c102b", "vicinity" : "Sydney" }, "status" : "OK" } 
+6
source share
1 answer

This feature is not supported. What you can do is create a map on MyMap and add a route for the path you want to highlight. You can then save it and export it as a KML layer. If you want to do this programmatically, you can use the Directions API to get the polyline for the route.

0
source

All Articles