Click here to Skip to main content
15,883,925 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
The Requirement -> When we search a place in google map it comes with a thin border around the searched place. I require that same thing in my angular app.

Here is the script which I am using in the code:- https://maps.googleapis.com/maps/api/jskey=&libraries=visualization,geometry,places

Open this link to what I am expecting: - https://i.stack.imgur.com/cWd6c.png

What I have tried:

app.component.html
HTML
<input type="text" id="pac-input" placeholder="Search.." class="form-control" maxlength="100"/>


app.component.ts
TypeScript
initAutocomplete() { 
    const input = document.getElementById('pac-input') as HTMLInputElement;
    const searchBox = new google.maps.places.SearchBox(input);
    const markers: google.maps.Marker[] = []; 
    searchBox.addListener('places_changed', () => {
      const places = searchBox.getPlaces();
      this.findOrganisation.Center = {};
      this.findOrganisation.GeoFence = [];
      if (places.length === 0) {
        this.showGeoCodeNotAvailable = true;
        return;
      }
      const resultPlace = places[0];
      this.findOrganisation.Address = resultPlace.formatted_address;
      if (!resultPlace.geometry) {
        this.registerService.getLatLngByLocation(resultPlace.formatted_address).subscribe((res) => {
          if (res['status'] === 'OK') {
            this.findOrganisation.Center = {
              Lat: res['results'][0].geometry.location.lat,
              Lng: res['results'][0].geometry.location.lng
            };
            this.findOrganisation.GeoFence = this.generateGeoJSONCircle(new google.maps.LatLng(this.findOrganisation.Center.Lat, this.findOrganisation.Center.Lng),
              this.distance, this.directions);
          } else {
            this.showGeoCodeNotAvailable = true;
          }
        }, (err) => {
          this.showGeoCodeNotAvailable = true;
        });
      } 
    });
  }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900