μλ
νμΈμ,
GoogleMapsAPIWrapper μλΉμ€μμμ§λ κ²½κ³λ₯Ό κ°μ Έ μ€λ €κ³ ν©λλ€.
Promiseλ₯Ό μ¬μ©νκ³ μμ΅λλ€.
μ무κ²λ λ°νλμ§ μμ΅λλ€.
μ¬κΈ° λ΄ μ½λκ° μμ΅λλ€.
constructor(private searchService: SearchService,
private wrapper: GoogleMapsAPIWrapper,
private _loader: MapsAPILoader,
private zone: NgZone) {
}
ngOnInit() {
this.wrapper.getBounds().then(x => console.log(x));
}
peomiseλ μ무κ²λ λ°ννμ§ μμΌλ―λ‘ console.log ν¨μλ νΈμΆλμ§ μμ΅λλ€.
κ°μ¬
@betfun ν
νλ¦Ώ λ΄μμμ΄ κ΅¬μ± μμλ₯Ό μ΄λμ λ°°μΉ νμ΅λκΉ? λ΄λΆ
λλ μ΄κ²μ μ§μ νκ³ μλνμ§λ μλλ€. μ΄κ²μ Componentμ μμλ€.
"getNativeMap"μ νΈμΆνκ³ "then"μ μνν΄λ μ ν νΈμΆλμ§ μμ΅λλ€.
ν
νλ¦Ώμ <sebm-google-maps>
μ΄μλ κ΅¬μ± μμμ λν΄ μλ ν λ λμΌν λ¬Έμ κ° λ°μνμ΅λλ€. λ΄ ν΄κ²° λ°©λ²μ νμν κΈ°λ₯μ μννκΈ° μν΄ <sebm-googe-maps><custom-component></custom-component></sebm-google-maps>
λ΄λΆμ λμ μ¬μ©μ μ§μ κ΅¬μ± μμλ₯Ό λ§λλ κ²μ΄ μμ΅λλ€.
λΉμ·ν λ¬Έμ κ° μμ΅λλ€. λ€μμ μλ ν λ :
this._wrapper.getNativeMap (). then ((map) => console.log ( "mappp", map));
mapppλ μΈμλμ§ μμ΅λλ€. μΈμ€ν΄μ€κ° sebm-google-map μΈμ€ν΄μ€μ λμΌν μ§ μ΄λ»κ² νμΈν μ μμ΅λκΉ?
μ΄λ€ λμμ μ£Όμλ©΄ κ°μ¬νκ² μ΅λλ€
μ§λλ₯Ό νμνλ MapComponentκ° μκ³ λ€λ₯Έ κ΅¬μ± μμμμ κ²½κ³λ₯Ό κ°μ Έμ€κ³ μΆμ΅λλ€. μ΄λ»κ²νλ©΄ λλμ?
λλ λν κ°μ λ¬Έμ λ₯Όλ³΄κ³ μλ€.
ν
νλ¦Ώ λ΄μμ sebm-google-map
κ΅¬μ± μμλ₯Ό μ¬μ©νλ©΄ λ€μμ μ¬μ©ν μ μμ΅λλ€.
<sebm-google-map (boundsChange)="boundsChange($event)"></sebm-google-map>
κ·Έλ° λ€μ κ΅¬μ± μμ λ΄λΆ :
boundsChange(event) {
console.log(event.getNorthEast().lat());
console.log(event.getNorthEast().lng());
console.log(event.getSouthWest().lat());
console.log(event.getSouthWest().lng());
}
@josueadelima κ°μ¬ν©λλ€!
μ΄κ²μ μ¬μ©μκ°μ§λλ₯Ό μ΄λν λλ§ μλνμ΅λλ€.
μ§λκ°λ‘λλκ³ μ¬μ©μκ° ν°μΉνμ§ μμμ λλ κ²½κ³λ₯Ό κ°μ ΈμμΌν©λλ€.
λΏ‘ λΉ΅λ¨
Angular4λ₯Ό μ¬μ©νμ¬ GoogleMapsAPIWrapperμ μ½μμ΄ μλνμ§ μμμ νμΈν μ μμ΅λλ€.
@craftpip μ§λλ‘λμ boundsChange μ΄λ²€νΈλ λ°κ³ μμ΅λλ€ ...
@craftpip μΈκΈ μ½μμ΄ μλνμ§ μμΌλ―λ‘ Angular4
sebm-google-map
ν
νλ¦Ώμ΄ μλ GoogleMapsAPIWrapperλ₯Ό μ¬μ©νμ¬μ§λλ₯Ό λ§λ€λ©΄ μλνμ§λ§ sebm-google-map
μ 곡νλ λ§μ κΈ°λ₯μ΄ μμ€ λ μ μμ΅λλ€.
λ‘λμ <agm-circle>
μ§μλ¬Έμμ getBoundsλ₯Ό μλνκ³ μμ΅λλ€. λ€μ΄ν°λΈ μμμ μ‘μΈμ€νλ €κ³ νμ§λ§ λ€μ΄ν°λΈ μμμμ AgmCircle κ°μ²΄λ₯Ό κ°μ Έμ¬ μ μμ΅λλ€.
this.circleManager.getBounds(this.searchCircle).then((bounds) => { console.log(bounds); });
http://plnkr.co/edit/nG6lUsm1KLbQRv3SRdgW?p=preview
μ΄κ²μ λν λμμ μ£Όμ μ κ°μ¬ν©λλ€.
μ΄κ²μ λν μμ μ¬νμ΄ μμ΅λκΉ? λλ κ°μ λ¬Έμ κ° μκ³ μ΄λ²€νΈλ₯Ό μ¬μ©νλ κ²μ΄ μ€μ λ‘ ν΄κ²°μ± μ΄ μλλλ€.
@jplew λλΆμ
μ΄λ° μμΌλ‘ κ²½κ³λ₯Ό μ»μ μ μμ΅λλ€;)
latNorth: number
@ViewChild(AgmMap) mapElement: any
...
checkBounds(map) {
const ln = this.mapElement._mapsWrapper.getBounds()
.then( (latLngBounds) => {
return latLngBounds.getNorthEast().lat()
})
ln.then( x => this.latNorth = x )
μ½μμ Angular 4μμ μ¬μ ν μλνμ§ μμ§λ§ μ΄κ²μ getBounds
ν¨μλΏλ§ μλλΌ μ½μμ΄ μ€νλμ§ μλ createMarker
μ κ°μ λ€λ₯Έ ν¨μμ
λλ€.
μ΄ λ¬Έμ λ μ΅κ·Ό νλμ΄ μμκΈ° λλ¬Έμ μλμΌλ‘ μ€λλ κ²μΌλ‘ νμλμμ΅λλ€. λ μ΄μ νλμ΄ λ°μνμ§ μμΌλ©΄ νμλ©λλ€. κ·νμ κΈ°μ¬μ κ°μ¬λ립λλ€.
μ¬μ ν κ°μ λ¬Έμ κ° μμ΅λλ€.
μ΄ λ¬Έμ λ μ΅κ·Ό νλμ΄ μμκΈ° λλ¬Έμ μλμΌλ‘ μ€λλ κ²μΌλ‘ νμλμμ΅λλ€. λ μ΄μ νλμ΄ λ°μνμ§ μμΌλ©΄ νμλ©λλ€. κ·νμ κΈ°μ¬μ κ°μ¬λ립λλ€.
μ§κΈλ μ¬μ ν κ°μ λ¬Έμ κ° μλλ° λκ΅°κ°κ° λ¬Έμ λ₯Ό μΌμΌμΌ°μ΅λκΉ?
μ GoogleAPIWrapperμ getBoundsλ₯Ό μ¬μ©νκ³ μμ΅λκΉ?
κ°μ₯ μ μ©ν λκΈ
λΏ‘ λΉ΅λ¨
Angular4λ₯Ό μ¬μ©νμ¬ GoogleMapsAPIWrapperμ μ½μμ΄ μλνμ§ μμμ νμΈν μ μμ΅λλ€.