如何获取由 PlaceId 表示的道路形状

How do I obtain shape of a road represented by a PlaceId

如果我有一个表示道路的 PlaceId,我怎样才能获得道路的形状以在地图上突出显示它?地点 API 仅 returns 道路几何字段中的一个位置。

例如给定的 PlaceID:ChIJ8R8rpjCuEmsRKxCMhhWn9Kg 我收到以下回复。请注意类型字段的值为 "route",但几何字段仅提供单个位置而不是路径。

{
   "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"
}

不支持此功能。您可以做的是在MyMap and add a driving route for the path you want to highlight. Then, you can save it and export it as a KML layer. If you wanted to do this programmatically, you could use the Directions API上创建一个地图来获取路线的折线。