feat(map) Autocomplete
See original GitHub issueI have gathered all the suggestions, tips, and my work together to provide an Autocomplete Solution:
boot:
bootstrap(AppComponent, [
GOOGLE_MAPS_PROVIDERS,
provideLazyMapsAPILoaderConfig({
apiKey: 'yourGoogleKey',
libraries: ['places'] }),
ROUTER_PROVIDERS
]);
map html:
<google-search-bar></google-search-bar>
<sebm-google-map
[latitude]="lat"
[longitude]="lng"
[zoom]="zoom"
[disableDefaultUI]="false"
[streetViewControl] = "false"
[zoomControl]="true"
(mapClick)="mapClicked($event)">
<sebm-google-map-marker *ngFor="let m of markers; let i = index"
(markerClick)="clickedMarker(i, $event)"
[latitude]="m.lat"
[longitude]="m.lng"
[markerDraggable]="m.draggable"
[iconUrl]="m.iconUrl"
(dragEnd)="markerDragEnd($event)">
<sebm-google-map-info-window
[isOpen]="m.isOpen">
<infowindow
[allEventMarkers]="markers"
[currentIndex]="i">
</infowindow>
</sebm-google-map-info-window>
</sebm-google-map-marker>
</sebm-google-map>
search bar:
Then Create an Angular ‘your-search-bar’ component with the following template:
<input type="text" id="your-search-bar" (click)="clearSearch()" class="form-control">
‘YourMapApp’: add the following:
constructor(private apiLoader: MapsAPILoader, private zone: NgZone) {
}
ngOnInit() {
this.apiLoader.load().then(() => {
let autocomplete = new google.maps.places.Autocomplete(document.getElementById('your-search-bar'), {});
google.maps.event.addListener(autocomplete, 'place_changed', () => {
this.zone.run(() => {
let place = autocomplete.getPlace();
if (place.geometry.location) {
this.lat = place.geometry.location.lat();
this.lng = place.geometry.location.lng();
}
});
});
});
}
Working awesome. Feedback please :)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:14
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Place Autocomplete | Maps JavaScript API - Google Developers
Autocomplete is a feature of the Places library in the Maps JavaScript API. You can use autocomplete to give your applications the type-ahead-search ......
Read more >feat(map) Autocomplete · Issue #467 - GitHub
I have gathered all the suggestions, tips, and my work together to provide an Autocomplete Solution: boot: bootstrap(AppComponent, [ GOOGLE_MAPS_PROVIDERS, ...
Read more >use-places-autocomplete - npm
Features ; Provides intelligent places suggestions powered by Google Maps Places API. ; Builds your own customized autocomplete UI by React ...
Read more >New Autocomplete features in Google Maps Platform help ...
With these new Autocomplete features in Google Maps Platform, your users will be able to find the exact place they're looking for, faster....
Read more >Address Autocomplete | Maps API - Geoapify
Address Autocomplete API for address inputs, HTML forms, and apps. NPM packages for easy integration and code samples. ... Features and capabilities.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe this will be helpful for someone:
Directive
and then in the html we just need to use it:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.