Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago .i wanna scroll to closet marker after a search. Console.log shows for pins[i] = (50.296322, 9.112082) und event (50.937531, 6.9602786). i tried many but always get: Cannot read properties of undefined (reading 'spherical')
function geocodeAddress(geocoder, resultsMap)< var address = document.getElementById('address').value; geocoder.geocode(, function(results, status) < if (status === 'OK') < function find_closest_marker(event)< var distances = []; var closest = -1; for(i = 0; i < pins.length; i++)< var d = google.maps.geometry.spherical.computeDistanceBetween(pins[i].position, event); distances[i] = d; if (closest == -1 || d < distances[closest])< closest = i; >> resultsMap.setCenter(pins[closest].position); > find_closest_marker(results[0].geometry.location); > else < alert('Geocode was not successful for the following reason: ' + status); >>);