-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Feature Description
I have a map loaded on my screen, but I also want to use the Places Api. Although geocoding is supported by the library, places is not.
The map, and map instance, are created solely through my template
<google-map [options]="options" class="col-sm-8">
<map-marker
[options]="markerOptions"
[position]="markerPosition"
></map-marker>
</google-map>
I have been trying the following code
const map1: any = document.querySelector("google-map") as unknown;
console.log("lookup", map1)
const map2: GoogleMap = map1;
var request = {
query: 'albina',
fields: ['name', 'geometry'],
};
var service = new google.maps.places.PlacesService(map2);
service.findPlaceFromQuery(request, (results, status) => console.log(results, status))
This works in javascript - the querySelector returns the dom node, but it can be passed successfully to PlacesService. As I am using typescript I keep being told that I can't pass an html element (not withstanding my attempts to override the type).
Really what I want is to access the map as is, rather than using dom lookups, but I cannot work out how to access that. As you can see, I am able to create and pass options to the component, but don't know angular well enough to get the map back
Use Case
I also want to use the Places Api which requires me to pass a google map. the obvious candidate is the one created by this component, but I cannot see how to access it