I'm having problems getting Google's Place Autocomplete Address Form to work in a Blazor Web Assembly app.
I'm using Google's documentation https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform
I include the JavaScript at the bottom of index.html. I have a js file that contains JavaScript per the documentation and I'm including the Places library from Google API.
<script src="js/googleAddressAutocomplete.js"></script>
<script
src="https://maps.googleapis.com/maps/api/js?key={MyApiKey}&callback=initAutocomplete&libraries=places&v=weekly"
defer
></script>
In the Blazor component, I'm using the same markup as the documentation.
<div id="locationField">
<input
id="autocomplete"
placeholder="Enter your address"
onFocus="@GeoLocate()"
type="text"/>
</div>
Except I'm calling a C# method which using JS Interop to call the Geolocate function.
private async Task GeoLocate()
{
await JSRuntime.GeoLocate();
}
When I run it, I get this error in the console: InvalidValueError: not an instance of HTMLInputElement
Looks like it can't find the input element, but I don't understand why. And I don't know what to do about it. I'm using the same code from Google's documentation, but migrating it to Blazor WASM. Can someone point me in the right direction? thanks, Dave