Angular-google-maps: μƒˆ μ•„μ΄μ½˜μ„ ν΄λ¦­ν•˜λ©΄ 마컀 정보 창을 λ‹«μœΌμ‹œκ² μŠ΅λ‹ˆκΉŒ?

에 λ§Œλ“  2016λ…„ 12μ›” 19일  Β·  23μ½”λ©˜νŠΈ  Β·  좜처: SebastianM/angular-google-maps

이것이 κ°€λŠ₯ν•©λ‹ˆκΉŒ?

stale discussion / question

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

λ‚΄ ν…œν”Œλ¦Ώ μ „μš© μ†”λ£¨μ…˜ :

<sebm-google-map #gm [latitude]="lat" [longitude]="lng" [zoom]="zoom" [scrollwheel]="false" [styles]="mapStyles">
    <sebm-google-map-marker *ngFor="let place of places"
    [latitude]="place.point.lat"
    [longitude]="place.point.lng"
    [label]="place.name[0]"
    (markerClick)="gm.lastOpen?.close(); gm.lastOpen = infoWindow">
    <sebm-google-map-info-window #infoWindow>
        <strong>{{place.name}}</strong>
    </sebm-google-map-info-window>
</sebm-google-map-marker>

λͺ¨λ“  23 λŒ“κΈ€

예, 이전에도 같은 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒμ€ μž‘λ™ν•˜λŠ” ν”Œλ ν¬μž…λ‹ˆλ‹€.
http://plnkr.co/edit/cwuwBN?p=preview

λ‚˜λŠ”μ΄ 접근법을 μ‚¬μš©ν•  수 μ—†μ—ˆλ‹€.
λ‚΄ μ†”λ£¨μ…˜μ€ μ†ŒμŠ€λ₯Ό λ‹€μš΄λ‘œλ“œν•˜κ³  파일 (google-map-info-window.ts)에 λ‹€μŒ μ½”λ“œλ₯Ό ν¬ν•¨ν•©λ‹ˆλ‹€.

// μ•„λž˜μ˜ μ΅œμƒμœ„ νŒŒμΌμ—μ΄ 속성을 μ„€μ •ν•©λ‹ˆλ‹€. let infoWindowId = 0; (7 ν–‰)
let infoWindowLastContext : SebmGoogleMapInfoWindow = null;

open () : 약속{
if (infoWindowLastContext! == null) {
this._infoWindowManager.close (infoWindowLastContext)
}

infoWindowLastContext = this;

return this._infoWindowManager.open(this);

}

이게 도움이 되길 λ°”λž€λ‹€...

λ‚΄ ν…œν”Œλ¦Ώ μ „μš© μ†”λ£¨μ…˜ :

<sebm-google-map #gm [latitude]="lat" [longitude]="lng" [zoom]="zoom" [scrollwheel]="false" [styles]="mapStyles">
    <sebm-google-map-marker *ngFor="let place of places"
    [latitude]="place.point.lat"
    [longitude]="place.point.lng"
    [label]="place.name[0]"
    (markerClick)="gm.lastOpen?.close(); gm.lastOpen = infoWindow">
    <sebm-google-map-info-window #infoWindow>
        <strong>{{place.name}}</strong>
    </sebm-google-map-info-window>
</sebm-google-map-marker>

νŠΈμœ— λ‹΄μ•„ κ°€κΈ°

<agm-map #gm [latitude]="lat" [longitude]="lng" [zoom]="zoom" [scrollwheel]="false" [styles]="mapStyles">
    <sebm-google-map-marker *ngFor="let place of places"
    [latitude]="place.point.lat"
    [longitude]="place.point.lng"
    [label]="place.name[0]"
    (markerClick)="gm.lastOpen?.close(); gm.lastOpen = infoWindow">
    <agm-info-window #infoWindow>
        <strong>{{place.name}}</strong>
    </agm-info-window>
</agm-marker>

μƒˆλ‘œμš΄ 1.0.0-beta.0-green-zebra AOTκ°€ μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
'AgmMap'μœ ν˜•μ— 'lastOpen'속성이 μ—†μŠ΅λ‹ˆλ‹€.

무슨 일이 일어날 수 μžˆμŠ΅λ‹ˆκΉŒ?

잘 μž‘λ™ν•©λ‹ˆλ‹€. λ‚΄ ν…œν”Œλ¦Ώ μ‚¬μš©μ€μ—μ„œμ™€ 같이 μ‚¬μš©μž 지정 클릭 κΈ°λŠ₯을 ν˜ΈμΆœν•©λ‹ˆλ‹€.

(markerClick)="gm.lastOpen?.close(); gm.lastOpen = infoWindow; markerClicked(m);"

μ•ˆλ…•ν•˜μ„Έμš”,

@ Martin-B μ†”λ£¨μ…˜μ„ μ‚¬μš©ν•΄λ„ μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

도움이 ν•„μš”ν•˜μ„Έμš”?

@ Martin-BλŠ” μ†”λ£¨μ…˜μ— κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€. 치료 νš¨κ³Όκ°€ μžˆμŠ΅λ‹ˆλ‹€!

@ Martin-B 쒋은 thx!
@melbouhy λΆ€λ„λŸ¬μ›Œ λ‚˜μ—κ²Œ; μΆ”κ°€ 깜빑 #infoWindow 에 <agm-info-window> . 당신도 같은 μ‹€μˆ˜λ₯Όν–ˆμ„κΉŒμš”?


곡개 openIW (데이터 = μ •μ˜λ˜μ§€ μ•ŠμŒ) {
if (this.IW) {
this.IW.close ();
}

this.IW = data;

}

@ Martin-B μ‚¬μš© 방법 ((markerClick) = "gm.lastOpen? .close (); gm.lastOpen = infoWindow; markerClicked (m);") agm-markerμ—μ„œ .ts μ½”λ“œλ‘œ λ‹΅μž₯ ν•΄μ£Όμ„Έμš”

@menakav λ‹€μŒμ€ μž‘λ™ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.
.ts 파일 :
`
markerClicked (infoWindow) {
if (this.infoWindowOpened === infoWindow)
λ°˜ν™˜;

    if(this.infoWindowOpened !== null)
    {
        this.infoWindowOpened.close();
    }

    this.infoWindowOpened = infoWindow;
}

in .html file: (markerClick) = "gm.lastOpen? .close (); gm.lastOpen = infoWindow; markerClicked (m);"`

@menakav κ·€ν•˜μ˜ μ½”λ“œκ°€ λ‚˜λ₯Ό μœ„ν•΄ μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
:(

이 포럼의 λͺ¨λ“  μ½”λ“œλ₯Ό ν…ŒμŠ€νŠΈν–ˆλŠ”λ° λ‚΄ λ¬Έμ œλŠ” μ—¬κΈ°μ—μ„œλ°›μ€ infoWindow .

  clickedMarker(infoWindow, index: number) {
    ...
  }

infoWindow λŠ” λ‚΄κ°€ μ–΄λ–€ 포인트λ₯Ό 가지고 μžˆλ”λΌλ„ 항상 첫 λ²ˆμ§Έμž…λ‹ˆλ‹€. 항상 _id = 0 인 infoWindow λ₯Ό λ°›μ•˜μŠ΅λ‹ˆλ‹€.

index 맀개 λ³€μˆ˜λŠ” 클릭 된 마컀의 μ‹€μ œ IDλ₯Όλ°›μŠ΅λ‹ˆλ‹€ ....

이것은 λ‚΄ HTMLμž…λ‹ˆλ‹€.

<agm-marker *ngFor="let point of points; let i = index" [latitude]="point.latitude"
                            [longitude]="point.longitude"
                            [iconUrl]="iconUrl" (markerClick)="clickedMarker(infoWindow, i)">
<agm-info-window [disableAutoPan]="true" #infoWindow *ngIf="!isDetailMovil">
        <div class="marker__tittle">{{point.name}}</div>

항상 λ™μΌν•œ infoWindowκ°€ λ‚˜μ˜€λŠ” μ΄μœ λŠ” λ¬΄μ—‡μž…λ‹ˆκΉŒ?

@soyersoyer 의 "ν…œν”Œλ¦Ώ μ „μš©"μ†”λ£¨μ…˜μ΄ ν›Œλ₯­ν•˜κ²Œ μž‘λ™ν•©λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ 초기 agm-marker 배열이 μƒˆ 마컀 μš”μ†Œλ‘œ ꡐ체되면 (예 : ajax μ—…λ°μ΄νŠΈ ν›„) κ°‘μžκΈ° 이전 정보 창이 더 이상 μžλ™μœΌλ‘œ λ‹«νžˆμ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μ—¬κΈ°μ„œ λ¬Έμ œλŠ” λ¬΄μ—‡μΌκΉŒμš”?

@markschmid 초기 agm-marker 배열이 ꡐ체 될 λ•Œμ˜ ν•΄κ²° λ°©λ²•μž…λ‹ˆλ‹€.
(markerClick)="tmp=gm.lastOpen;gm.lastOpen=infoWindow;tmp?.close();"

@lauwrentius 닡변을 기반으둜 ν•œ λ‚΄ μ†”λ£¨μ…˜ :

* .html

<agm-marker 
    *ngFor="let marker of markers; let i = index"
    (markerClick)="showInfoWindow(infoWindow, i)"
>
    <agm-info-window #infoWindow></agm-info-window>
</agm-marker>

* .ts

infoWindowOpened = null;

filter() {
    infoWindowOpened = null;
    // redraw the map with filtered markers
}

showInfoWindow(infoWindow, index) {
    if (this.infoWindowOpened === infoWindow) {
        return;
    }

    if (this.infoWindowOpened !== null) {
        this.infoWindowOpened.close();
    }

    this.infoWindowOpened = infoWindow;   
}

μ•ˆλ…•ν•˜μ„Έμš”.

였λ₯˜λ‘œ 'infoWindowOpenedλ₯Ό 찾을 수 μ—†μŒ'을 ν‘œμ‹œν•˜μ§€ μ•Šκ³  filter(){infoWindowOpened = null;} λ₯Ό μ‹€ν–‰ν•˜λŠ” 방법을 μ„€λͺ… ν•  수 μžˆμŠ΅λ‹ˆκΉŒ? 이것은 마컀 μ•„μ΄μ½˜ 배열을 λ³€κ²½ ν•œ 후에 λ°œμƒν•©λ‹ˆλ‹€.

λ‚˜λŠ” 문제λ₯Ό ν•΄κ²°ν–ˆλ‹€.
μ½”λ“œλ₯Ό κ³΅μœ ν–ˆμŠ΅λ‹ˆλ‹€.
(markerClick) = "clickedMarker (infoWindow, point, point.latitude, point.longitude)">

clickedMarker (data = undefined, currentPoint : any, lat : string, lng : string) {
if (this.IW) {
this.IW.close ();
}
const μ„ΈλΆ€ 정보 = data._infoWindowManager._infoWindows;
if (details.size> 0) {
details.forEach ((μš”μ†Œ, ν‚€) => {
if (key.hostMarker.latitude === lat && key.hostMarker.longitude === lng) {
this.IW = ν‚€;
}
});
}
}

λ‚˜λŠ” 그것이 λ„μ›€μ΄λ˜κΈ°λ₯Ό λ°”λžλ‹ˆλ‹€.

κ°μ‚¬ν•©λ‹ˆλ‹€.

2018 λ…„ 4 μ›” 28 일 ν† μš”μΌ 02:04, Cristian Hernandez [email protected]
썼닀 :

λ‚˜λŠ” 문제λ₯Ό ν•΄κ²°ν–ˆλ‹€.
μ½”λ“œλ₯Ό κ³΅μœ ν–ˆμŠ΅λ‹ˆλ‹€.
[latitude] = "point.latitude"[longitude] = "point.longitude"
[iconUrl] = "iconUrl"(markerClick) = "clickedMarker (infoWindow, 포인트,
point.latitude, point.longitude) "> [disableAutoPan] = "true"* ngIf = "! isDetailMovil">

clickedMarker (data = undefined, currentPoint : any, lat : string, lng :
λ¬Έμžμ—΄) {if (this.IW) {this.IW.close (); } const μ„ΈλΆ€ 사항 =
data._infoWindowManager._infoWindows; if (details.size> 0) {
details.forEach ((μš”μ†Œ, ν‚€) => {if (key.hostMarker.latitude === lat &&
key.hostMarker.longitude === lng) {this.IW = ν‚€; }}); }}

λ‚˜λŠ” 그것이 λ„μ›€μ΄λ˜κΈ°λ₯Ό λ°”λžλ‹ˆλ‹€.

β€”
당신이 μ–ΈκΈ‰ λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›κ³  μžˆμŠ΅λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/SebastianM/angular-google-maps/issues/797#issuecomment-385086695 ,
λ˜λŠ” μŠ€λ ˆλ“œ μŒμ†Œκ±°
https://github.com/notifications/unsubscribe-auth/AgIM0TGCgyHK-snaJdIlSZSQuq0MF1Ihks5ts4DDgaJpZM4LQ0M7
.

μ—¬κΈ° λ‚΄ 해결책이 μžˆμŠ΅λ‹ˆλ‹€. 각도 6κ³Ό ν•¨κ»˜ μž‘λ™ν•©λ‹ˆλ‹€.
HTML :

<agm-marker *ngFor="let marker of markers" [latitude]="marker.latitude"[longitude]="marker.longitude" (markerClick)="markerClick(infoWindow)">
<agm-info-window #infoWindow>
</agm-info-window>
</agm-marker>

TypeScript :

lastSelectedInfoWindow: any;
markerClick(infoWindow: any) {
        if (infoWindow == this.lastSelectedInfoWindow) {
            return;
        }
        if (this.lastSelectedInfoWindow != null) {
         try{
            this.lastSelectedInfoWindow.close();
          } catch {} //in case if you reload your markers
        }
        this.lastSelectedInfoWindow = infoWindow;
    }

였랜 연ꡬ와 λΆˆλΆ„λͺ… ν•œ μ†”λ£¨μ…˜ 끝에 λ§ˆμΉ¨λ‚΄ μƒˆλ‘œμš΄ agm-info-windowκ°€ 열릴 λ•Œ λͺ…ν™•ν•œ 이전 agm-info-window에 λŒ€ν•œ ν›Œλ₯­ν•œ μ†”λ£¨μ…˜μ„ μ–»μ—ˆμŠ΅λ‹ˆλ‹€.

이것은 λ‚΄ component.htmlμž…λ‹ˆλ‹€.

 <agm-map (mapClick)="close_window($event)" [fullscreenControl]='true' [mapTypeControl]='true' [latitude]="lat" [longitude]="lng" [zoom]="13" [scrollwheel]="false">
     <div *ngFor="let data of zonas">
        <agm-marker (markerClick)=select_marker(infoWindow) [latitude]="data.latitud" [longitude]="data.longitud">
           <agm-info-window #infoWindow >            
           </agm-info-window>
         </agm-marker>
      </div>
  </agm-map>

그리고 이것은 λ‚΄ component.tsμž…λ‹ˆλ‹€.

constructor(public apiService: ApiService) {}
infoWindowOpened = null
previous_info_window = null
...
close_window(){
if (this.previous_info_window != null ) {
  this.previous_info_window.close()
  }    
}

select_marker(data,infoWindow){
 if (this.previous_info_window == null)
  this.previous_info_window = infoWindow;
 else{
  this.infoWindowOpened = infoWindow
  this.previous_info_window.close()
 }
 this.previous_info_window = infoWindow
}

λ”°λΌμ„œ μƒˆ 창이 열릴 λ•Œλ§ˆλ‹€ 이벀트λ₯Ό κ°μ§€ν•˜κ³  이전 창을 λ‹«μŠ΅λ‹ˆλ‹€. λ˜ν•œ μ‚¬μš©μžκ°€μ§€λ„μ˜ λ‹€λ₯Έ λΆ€λΆ„μ—μ„œ μ°½ μ™ΈλΆ€λ₯Ό ν΄λ¦­ν•˜λ©΄ μ—΄λ¦° 창을 λ‹«λŠ”λ°λ„ μž‘λ™ν•©λ‹ˆλ‹€.

@JimmyTheNerd 감사

@lauwrentius 닡변을 기반으둜 ν•œ λ‚΄ μ†”λ£¨μ…˜ :

* .html

<agm-marker 
    *ngFor="let marker of markers; let i = index"
    (markerClick)="showInfoWindow(infoWindow, i)"
>
    <agm-info-window #infoWindow></agm-info-window>
</agm-marker>

* .ts

infoWindowOpened = null;

filter() {
    infoWindowOpened = null;
    // redraw the map with filtered markers
}

showInfoWindow(infoWindow, index) {
    if (this.infoWindowOpened === infoWindow) {
        return;
    }

    if (this.infoWindowOpened !== null) {
        this.infoWindowOpened.close();
    }

    this.infoWindowOpened = infoWindow;   
}

κ°μ‚¬ν•©λ‹ˆλ‹€ @JimmyTheNerd , μž‘λ™ν•©λ‹ˆλ‹€.

이 λ¬Έμ œλŠ” 졜근 ν™œλ™μ΄ μ—†μ—ˆκΈ° λ•Œλ¬Έμ— μžλ™μœΌλ‘œ 였래된 κ²ƒμœΌλ‘œ ν‘œμ‹œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. 더 이상 ν™œλ™μ΄ λ°œμƒν•˜μ§€ μ•ŠμœΌλ©΄ νμ‡„λ©λ‹ˆλ‹€. κ·€ν•˜μ˜ 기여에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰