Hi
I have found some examples using Google places API to autocomplete an address.
And I want to get the lat / lon from the returned result.
I'm struggling with getting the lat/lon values back in msg.payload.xxx.
I can fine see the values in "console.log" (F12), but how do I get this console.log into something i can process.
[{"id":"326bdf59fd90dd51","type":"template","z":"bd6851c447e9acc8","name":"JavaScript","field":"payload.script","fieldType":"msg","format":"javascript","syntax":"plain","template":"// This sample requires the Places library. Include the libraries=places\n// parameter when you first load the API. For example:\n// <script\n// src=\"https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places\">\nfunction initMap() {\n const node = this;\n const map = new google.maps.Map(document.getElementById(\"map\"), {\n center: { lat: -33.8688, lng: 151.2195 },\n zoom: 13,\n });\n const input = document.getElementById(\"pac-input\");\n // Specify just the place data fields that you need.\n const autocomplete = new google.maps.places.Autocomplete(input, {\n fields: [\"place_id\", \"geometry\", \"name\", \"formatted_address\"],\n });\n\n autocomplete.bindTo(\"bounds\", map);\n map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);\n\n const infowindow = new google.maps.InfoWindow();\n const infowindowContent = document.getElementById(\"infowindow-content\");\n\n infowindow.setContent(infowindowContent);\n\n const geocoder = new google.maps.Geocoder();\n const marker = new google.maps.Marker({ map: map });\n\n marker.addListener(\"click\", () => {\n infowindow.open(map, marker);\n });\n autocomplete.addListener(\"place_changed\", () => {\n infowindow.close();\n\n const place = autocomplete.getPlace();\n\n if (!place.place_id) {\n return;\n }\n\n geocoder\n .geocode({ placeId: place.place_id })\n .then(({ results }) => {\n map.setZoom(11);\n map.setCenter(results[0].geometry.location);\n // Set the position of the marker using the place ID and location.\n // @ts-ignore TODO This should be in @typings/googlemaps.\n marker.setPlace({\n placeId: place.place_id,\n location: results[0].geometry.location,\n });\n marker.setVisible(true);\n infowindowContent.children[\"place-name\"].textContent = place.name;\n infowindowContent.children[\"place-id\"].textContent = place.id;\n infowindowContent.children[\"place-address\"].textContent =\n results[0].formatted_address;\n infowindow.open(map, marker);\n\n // Here you can get your coordinates like this\n console.log(place.geometry.location.lat());\n console.log(place.geometry.location.lng());\n console.log(\"Test\");\n \n })\n .catch((e) => window.alert(\"Geocoder failed due to: \" + e));\n });\n}\n\nwindow.initMap = initMap;","output":"str","x":1106.0000534057617,"y":858,"wires":[["ad0566d863a022b4"]]}]