<button nz-button nzType="primary" style="margin-left: 8px;" (click)="searchplace()">
<i nz-icon nzType="search"></i>
查询地点
</button>
searchplace() {
console.log('执行了搜索')
this.geoCode()
}
geoCode() {
console.log('执行了Geocoder', this.searchValue)
let that = this
var marker = new this.AMap.Marker()
let geocoder = new this.AMap.Geocoder({})
geocoder.getLocation(that.searchValue, function (status, result) {
console.log('status', status)
if (status === 'complete' && result.geocodes.length) {
var lnglat = result.geocodes[0].location
// document.getElementById('lnglat').value = lnglat
marker.setPosition(lnglat)
that.map.add(marker)
that.map.setFitView(marker)
} else {
console.log('根据地址查询位置失败')
}
})
}