angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

Find and animate a Marker when focus an element outside the Map

Open RadouaneRoufid opened this issue 9 years ago • 2 comments

Hi everybody,

I have a search result displayed on two parts. The first one displays the result in form of a list. The second one displays the result in a Map using markers. Each marker corresponds to an element of the list.

My need is to animate the marker when the corresponding element of the list is focused.

My code :

export class SearchComponent implements OnInit {
markers: google.maps.Marker[];

    onWorkerFocus(workerUuid: string) {

        let aMarker: google.maps.Marker = this.markers.find(m => m.get("id") === workerUuid);

        if (aMarker) {
            aMarker.setAnimation(google.maps.Animation.BOUNCE);
        }
        
    }

search() {
this.searchService.search(this.searchFilter, this.pageable).subscribe((page: Page<WorkerDto>) => {

...

            for (let worker of this.workers) {
                let marker = new google.maps.Marker();
                let latLng = new google.maps.LatLng(worker.profile.address.latitude, worker.profile.address.longitude);
                marker.setPosition(latLng);
                marker.set("id", worker.uuid);
                this.markers.push(marker);
                this.bounds.extend(latLng);
            }

           ...
        });
}
}

My template

 <div *ngFor="let worker of page.content | paginate: { itemsPerPage: page.size, currentPage: currentPage, totalItems: page.totalElements }"
                     class="hoverable search-result">

                    <div class="card w-card" [id]="worker.uuid" (mouseenter)="onWorkerFocus(worker.uuid)" (mouseleave)="onWorkerFocusOut(worker.uuid)">
...
</div>
</div>


<sebm-google-map  #gm *ngIf="!loading" [latitude]="latitude" [longitude]="longitude"
                                         [fitBounds]="bounds">

                            <sebm-google-map-marker *ngFor="let worker of workers"
                                                    [latitude]="worker.profile?.address?.latitude"
                                                    [longitude]="worker.profile?.address?.longitude"
                                                    (markerClick)="gm.lastOpen?.close(); gm.lastOpen = infoWindow">>
                                <sebm-google-map-info-window #infoWindow [disableAutoPan]="true">
                                    ...
                                </sebm-google-map-info-window>
                            </sebm-google-map-marker>

                        </sebm-google-map>

Markers are not animated using this code.

What I'm doing wrong please ?

Thank you.

RadouaneRoufid avatar Mar 18 '17 18:03 RadouaneRoufid

Animations are not supported right now and the question is mainly related to the google maps api. Feel free to ask that question in the Gitter chatroom or on stackoverflow. Thank you!

sebholstein avatar Mar 30 '17 19:03 sebholstein

i want to have a infowindow loading for a particular marker and i tried but i am getting an infowindow coming for all the markers

menakav avatar Dec 08 '17 10:12 menakav