get nearest places first when search in google autocomplete places drop down in angular 2 -
i using google autocomplete locations in angular 2 project , filling locations in drop down. have new requirement.if user in place called abd , when doing search in drop down must shows abd first not abc,which means nearest places user must comes in drop down first.
the autocomplete location code had written given below
autocompletelocation() { this.mapsapiloader.load().then(() => { let autocomplete = new google.maps.places.autocomplete(this.searchelementref.nativeelement, { }); autocomplete.addlistener("place_changed", () => { this.ngzone.run(() => { //get place result let place: google.maps.places.placeresult = autocomplete.getplace(); //verify result if (place.geometry === undefined || place.geometry === null) { return; } //set latitude, longitude , zoom this.locinsertobj.prelocation = place.formatted_address; //place.name; this.locinsertobj.prelocation = this.locinsertobj.prelocation.indexof(place.name) < 0 ? place.name + ", " + this.locinsertobj.prelocation : this.locinsertobj.prelocation; this.locinsertobj.prelocationlat = place.geometry.location.lat(); this.locinsertobj.prelocationlong = place.geometry.location.lng(); this.locinsertobj.zip = 123; this.iscurrentlocationset = true; $(".userprofile-container").trigger("click"); $("#location").focus(); }); }); }); }
Comments
Post a Comment