|
|
@@ -28,6 +28,10 @@
|
|
|
|
|
|
componentDidMount () {
|
|
|
this.searchBar.focus()
|
|
|
+ if (!window.BMap) {
|
|
|
+ console.warn('百度地图未加载,搜索功能将不可用')
|
|
|
+ return
|
|
|
+ }
|
|
|
const { BMap } = window
|
|
|
let that = this
|
|
|
this.localSearch = new BMap.LocalSearch(this.map,
|
|
|
@@ -61,9 +65,9 @@
|
|
|
center,
|
|
|
searchList,
|
|
|
} = this.state
|
|
|
-
|
|
|
+ const showSearchResults = !!window.BMap;
|
|
|
const searchItems = []
|
|
|
- if (searchList) {
|
|
|
+ if (showSearchResults && searchList) {
|
|
|
searchList.forEach((item, index) => {
|
|
|
searchItems.push(
|
|
|
<div
|