-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use current location #2
Comments
Hi @balajivmdu , I`m not sure but looks like google places autocomplete does not have functionality to receive current position https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete?hl=en Probably you need to use geolocation service from https://developers.google.com/maps/documentation/javascript/geolocation |
I've managed to get current location using HTML Geolocation API. But how to cast it to Here's my code: options.model.ts import { Options as PlacesOptions } from 'ngx-google-places-autocomplete/objects/options/options';
import { ComponentRestrictions } from 'ngx-google-places-autocomplete/objects/options/componentRestrictions';
import { LatLngLiteral } from 'ngx-google-places-autocomplete/objects/latLng';
export class Options extends PlacesOptions {
public componentRestrictions : ComponentRestrictions = new ComponentRestrictions({
country: 'BR'
});
// public bounds: LatLngBounds = [];
constructor(opt?: Partial<PlacesOptions>) {
super(opt);
/* Gets users current geolocation */
if (this.bounds === undefined && window.navigator.geolocation) {
window.navigator.geolocation.watchPosition(
(position) => {
let latlng : LatLngLiteral = {
lat: position.coords.latitude,
lng: position.coords.longitude
}
this.bounds = {
latLng: latlng
}
}
);
}
}
} |
Am beginner to Angular. Its awesome tool to use and easy to use.
But my issue us , Its not showing "Current location" option in autocomplete.
Please help me in this.
The text was updated successfully, but these errors were encountered: