| | |
| | | <div style="display: flex">
|
| | | <div style="display: flex; width: 300px">
|
| | | <div>地址:</div>
|
| | | <a-input
|
| | | <!-- <a-input
|
| | | placeholder="关键字搜索"
|
| | | id="tipinput"
|
| | | style="width: 160px; height: 26px"
|
| | | ></a-input>
|
| | | ></a-input> -->
|
| | | <!-- <a-input
|
| | | v-model="input"
|
| | | placeholder="关键字搜索"
|
| | |
| | | style="width: 160px; height: 26px"
|
| | | @change="searchMap"
|
| | | ></a-input> -->
|
| | | <input v-model="input" id="tipinput" /><a-button
|
| | | @click="searchAddress"
|
| | | type="primary"
|
| | | style="margin-left:5px"
|
| | | >
|
| | | 搜索
|
| | | </a-button>
|
| | | <div id="panel"></div>
|
| | | <!-- <a-button
|
| | | size="small"
|
| | | type="primary"
|
| | |
| | | :zoom="zoom"
|
| | | :scroll-wheel-zoom="true"
|
| | | style="height: 400px; width: 100%; margin-top: 20px"
|
| | | id="amap"
|
| | | >
|
| | | <el-amap-marker
|
| | | :position="clickPoint"
|
| | |
| | | :dragging="true"
|
| | | ></el-amap-marker>
|
| | | </el-amap>
|
| | |
|
| | | <!-- :scroll-wheel-zoom="true"-->
|
| | | <!-- <baidu-map
|
| | | :center="center"
|
| | |
| | | } from 'vue-property-decorator';
|
| | | import any = jasmine.any;
|
| | | import { get, post } from "@/util/request";
|
| | | import $ from 'jquery'
|
| | | import func from 'vue-temp/vue-editor-bridge';
|
| | |
|
| | |
|
| | | @Component({
|
| | |
| | | // this.center.lat = newVal.lat
|
| | | }
|
| | | private created() {
|
| | | console.log(this.clickPoint,'clickPoint');
|
| | | // console.log(this.clickPoint,'clickPoint');
|
| | | }
|
| | |
|
| | | // 初始化地图
|
| | |
| | | // this.zoom = 19
|
| | |
|
| | | // }
|
| | | private selectPoi(e){
|
| | | console.log(e);
|
| | | let poi = e
|
| | | if (poi.length > 0) {
|
| | | this.clickPoint = [poi[0].lng, poi[0].lat]
|
| | | }
|
| | | }
|
| | | // private selectPoi(e){
|
| | | // console.log(e);
|
| | | // let poi = e
|
| | | // if (poi.length > 0) {
|
| | | // this.clickPoint = [poi[0].lng, poi[0].lat]
|
| | | // }
|
| | | // }
|
| | | private input:any=''
|
| | | private mark:any=''
|
| | | private searchMap(){
|
| | | var autoOptions = {
|
| | | input: "tipinput"
|
| | | };
|
| | | var auto = new AMap.AutoComplete(autoOptions);
|
| | | const placeSearch = new AMap.PlaceSearch(this.input);
|
| | | console.log(window);
|
| | | auto.on("select", select);//注册监听,当选中某条记录时会触发
|
| | | function select(e) {
|
| | | console.log(e.poi.adcode);
|
| | | placeSearch.setCity(e.poi.adcode);
|
| | | placeSearch.search(e.poi.name); //关键字查询查询
|
| | | // private searchMap(){
|
| | | // var autoOptions = {
|
| | | // input: "tipinput"
|
| | | // };
|
| | | // var self=this
|
| | | // var auto = new AMap.Autocomplete(autoOptions);
|
| | | // const placeSearch = new AMap.PlaceSearch(self.input);
|
| | | // // console.log(window);
|
| | | // auto.on("select", select);//注册监听,当选中某条记录时会触发
|
| | | // function select(e) {
|
| | | // placeSearch.setCity(e.poi.adcode);
|
| | | // placeSearch.search(e.poi.name); //关键字查询查询
|
| | | // self.clickPoint = [e.poi.location.lng, e.poi.location.lat]
|
| | | // }
|
| | | // }
|
| | | private searchAddress() {
|
| | | var map = new AMap.Map("amap", {
|
| | | resizeEnable: true
|
| | | });
|
| | | var placeSearch = new AMap.PlaceSearch({ |
| | | pageSize: 5, // 单页显示结果条数
|
| | | pageIndex: 1, // 页码
|
| | | city: "全国", // 兴趣点城市
|
| | | citylimit: false, //是否强制限制在设置的城市内搜索
|
| | | panel: "panel", // 结果列表将在此容器中进行展示。
|
| | | map: map, // 展现结果的地图实例
|
| | | autoFitView: true // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
|
| | | });
|
| | | //关键字查询
|
| | | placeSearch.search(this.input)
|
| | | var salf=this
|
| | | var markerone=0
|
| | | map.on('click',click);
|
| | | function click(e){
|
| | | if(markerone===1){
|
| | | map.remove(map.Marker)
|
| | | }
|
| | | salf.mapClick(e)
|
| | | map.Marker=new AMap.Marker({
|
| | | map: map,
|
| | | position: salf.clickPoint,
|
| | | animation:"AMAP_ANIMATION_BOUNCE"
|
| | | })
|
| | | markerone=1
|
| | | }
|
| | | |
| | | // 关键字查询
|
| | | // console.log(this.input);
|
| | | // placeSearch.search(this.input, (status, result) => {
|
| | | // // 查询成功时,result即对应匹配的POI信息
|
| | | |
| | | // console.log(result);//打印这句话报错,第一遍可以打印出来,第二遍就会报错
|
| | | // });
|
| | | // // 监听选中节点事件
|
| | | // AMap.event.addListener(placeSearch, "selectChanged", (SelectChangeEvent) => {
|
| | | // // 获取节点信息自行处理逻辑代码
|
| | | // this.mark = SelectChangeEvent.selected.data;
|
| | | // console.log(SelectChangeEvent.selected.data,'苏轼');
|
| | | // }); |
| | |
|
| | | }
|
| | | // function click(e){
|
| | | // console.log(e);
|
| | | // salf.clickPoint=[e.lnglat.lng,e.lnglat.lat]
|
| | | // }
|
| | | // placeSearch.search(this.input,function(status, result){
|
| | | // console.log(result);
|
| | | // auto.on('click',click);
|
| | | // function click(e){
|
| | | // console.log(e);
|
| | | // }
|
| | | // });
|
| | | // console.log(this.input);
|
| | | }
|
| | | // 初始定位到星虹国际
|
| | | private clickPoint: any = this.lnglat === '' ? [
|
| | | 120.720262,
|
| | |
| | | ]
|
| | |
|
| | | private mapClick(e: any) {
|
| | | // console.log(e);
|
| | | const { lng, lat } = e.lnglat
|
| | | this.clickPoint=[ lng, lat]
|
| | | this.$forceUpdate()
|
| | | // console.log(this.clickPoint);
|
| | | console.log(this.clickPoint);
|
| | | }
|
| | |
|
| | | private handleMapCancel() {
|
| | |
| | | }
|
| | | .amap-sug-result {
|
| | | position: absolute;
|
| | | z-index: 9999 !important;;
|
| | | z-index: 9999 !important;
|
| | | background-color: #fefefe;
|
| | | border: 1px solid #d1d1d1;
|
| | | bottom: auto;
|
| | | }
|
| | | #panel {
|
| | | z-index: 999;
|
| | | position: absolute;
|
| | | background-color: white;
|
| | | max-height: 100%;
|
| | | overflow-y: auto;
|
| | | left: 25px;
|
| | | width: 280px;
|
| | | top: 126px;
|
| | | }
|
| | | </style>
|