⼀、⾃定义⼀个百度地图控件:
该控件包括⼀个输⼊框,⽤于输⼊要搜索的地址;⼀个路线按钮,点击后弹出⾯板,⽤于选择出⾏⽅式和输⼊始终点;⼀个搜索按钮。
<bm-control>
<div id="searchbox" class="clearfix">
<div id="searchbox-container">
<div id="sole-searchbox-content" class="searchbox-content" >
<input id="sole-input" class="searchbox-content-common cc_cursor" type="text" name="word" autocomplete="off" maxlength="256"
placeholder="搜地点"
v-model="keyword">
<div class="input-clear cc_pointer" title="清空" ></div>
<div class="searchbox-content-button right-button loading-button cc_pointer route-button"
data-title="路线" data-tooltip="1" @click="showPanel">
<!-- <i class="el-icon-position" id="luxian"></i>-->
<!-- <i id="luxian"></i>-->
<button id="luxian-button"></button>
<!-- ::before-->
</div>
</div>
<div id="route-searchbox-content" class="searchbox-content route-searchbox-content bus" >
晋察冀是哪三省的简称<div class="route-header">
<div class="searchbox-content-common route-tabs cc_cursor">
<!-- <el-checkbox-group-->
<!-- :min="1"-->
<!-- :max="1">-->
<div class="tab-item bus-tab cc_pointer" data-index="bus">
<el-checkbox v-model="checkedBus">
<i></i>
<span>公交</span>
</el-checkbox>
</div>
陈意涵<div class="tab-item drive-tab cc_pointer" data-index="drive">
<el-checkbox v-model="checkedDrive">
<i></i>
<span>驾车</span>
</el-checkbox>
</div>
<div class="tab-item walk-tab cc_pointer" data-index="walk">
<el-checkbox v-model="checkedWalk">
<i></i>
<span>步⾏</span>
</el-checkbox>
</div>
<div class="tab-item bike-tab cc_pointer" data-index="bike">
<el-checkbox v-model="checkedBike">
<i></i>
<span>骑⾏</span>
</el-checkbox>
</div>
<!-- </el-checkbox-group>-->
拍了拍在哪里<div class="arrow-wrap"></div>
</div>
</div>
<div class="routebox cc_cursor">
<div class="searchbox-content-common routebox-content">
<div class="routebox-revert cc_pointer" title="切换起终点">
<div class="routebox-revert cc_pointer" title="切换起终点">
<div class="routebox-revert-icon cc_pointer">
</div>
</div>
<div class="routebox-inputs cc_cursor">
<div class="routebox-input route-start cc_cursor">
<div class="route-input-icon">
</div>
<input autocomplete="off" maxlength="256" placeholder="输⼊起点"
class="route-start-input cc_cursor" type="text"
v-model="startKeyword">
四喜丸子是什么地方的菜<div class="input-clear" title="清空" >
</div>
<div class="route-input-add-icon">
</div>
</div>
<div class="routebox-input route-end">
<div class="route-input-icon">
</div>
<input autocomplete="off" maxlength="256" placeholder="输⼊终点" class="route-end-input cc_cursor" type="text" v-model="endKeyword">
<div class="input-clear" title="清空" >
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<button id="search-button" data-title="搜索" data-tooltip="2"></button>
</div>
</bm-control>
点击路线按钮显⽰⾯板:
//显⽰⾯板
showPanel(){
// console.log("showPanel")
var data = ElementById('route-searchbox-content').style.cssText
console.log(data)
// display: none;
if(data =="display: block;"){
}else if(data =="display: none;"){
}
}
⼆、使⽤vue-baidu-map的组件
使⽤v-if,选中哪种出⾏⽅式,就使⽤哪个组件。
<!--搜索地点-->
起泡胶无胶水怎么做<bm-local-search :keyword="keyword" :auto-viewport="true" :location="北京"></bm-local-search>
<!--公交路线规划-->
<div v-if="checkedBus">
<bm-transit :start="startKeyword" :end="endKeyword" :auto-viewport="true" location="北京"></bm-transit> </div>
<!--驾车路线规划-->
<div v-if="checkedDrive">
<bm-driving :start="startKeyword" :end="endKeyword" :auto-viewport="true" location="北京"></bm-driving> </div>
<!--⾏⾛路线规划-->
<div v-if="checkedWalk">
<bm-walking :start="startKeyword" :end="endKeyword" :auto-viewport="true" location="北京"></bm-walking> </div>
功能可以实现,但是不够⼈性化。必要的时候可以使⽤原⽣⽅法实现更多需求。
发布评论