Skip to content
内容大纲
官方QQ交流群
pc端ui:468705115   点此加入
移动端ui:468217742   点此加入
技术交流1:87208295   点此加入
技术交流2:787747122   点此加入
官网
云控制台
开放平台
关注微信公众号
代码仓库: 码云

cv-geo-local 带地图选择的地址输入框

简要

带地图选择的地址输入框,一般和表单配合使用,默认为实心白色背景。

示例

vue
<template>
  <view class="content">
    <view class="components-title">
      <view class="components-title-t">cv-geo-local</view>
      <view class="components-title-d">可在地图中选择地址</view>
    </view>
    <view class="components-info">
      <view class="components-info-list" v-if="location_data">
        <view class="components-info-list-title">@onLocation:</view>
        <view class="components-info-list-item">
          <!--  #ifdef  MP-WEIXIN -->
          <view v-for="(item, key) in location_data" :key="key">
            <text>&Prime;{{ key }}&Prime;:</text>
            <text>{{ ' &Prime;' + item + '&Prime;' }}</text>
          </view>
          <!--  #endif -->
          <!--  #ifndef  MP-WEIXIN -->
          <text>{{ location_data }}</text>
          <!--  #endif -->
        </view>
      </view>
      <view class="components-info-list-tip" v-else>
        <view><text>未选择</text></view>
        <view><text>点击输入框右侧搜索按钮选择地址</text></view>
      </view>
    </view>
    <cv-form-base ref="refFormBase" :rules="formRules" :model="formData" style="padding: 0 10px" labelWidth="84">
      <cv-form-item label="详细地址1">
        <cv-geo-local v-model="formData.address1" @location="onLocation" />
      </cv-form-item>
      <cv-form-item label="详细地址2" labelPosition="top">
        <cv-geo-local v-model="formData.address2" @location="onLocation" isShowMap />
        <template v-slot:tip>有地图</template>
      </cv-form-item>
      <cv-form-item label="详细地址3" labelPosition="top">
        <cv-geo-local v-model="formData.address3" @location="onLocation" :location="location" isShowMap />
        <template v-slot:tip>有地图和默认地理位置</template>
      </cv-form-item>
    </cv-form-base>
    <view style="height: 50px"></view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      formRules: {},
      formData: {
        address1: '',
        address2: '',
        address3: ''
      },
      location: {},
      location_data: null
    };
  },
  onLoad() {
    setTimeout(() => {
      this.formData = {
        address1: '福建省福州市仓山区浦上大道198号123132',
        address3: '福建省福州市仓山区浦上大道198号'
      };
      this.location = {
        latitude: '26.040905',
        longitude: '119.279148'
      };
    }, 1000);
  },
  methods: {
    onLocation(e) {
      this.location_data = e;
    }
  }
};
</script>

<style>
.components-info {
  background-color: #ffffff;
  padding: 10px;
}
.components-info-title {
  text-align: center;
  line-height: 40px;
  font-size: 16px;
}
.components-info-list,
.components-info-list-tip {
  margin: 20px 0;
}
.components-info-list-tip {
  text-align: center;
  font-size: 12px;
  color: #99999999;
}
.components-info-list-title {
  font-size: 12px;
  color: #999999;
}
.components-info-list-item {
  font-size: 12px;
  color: #666666;
  padding-left: 40px;
}
</style>

属性

属性名类型默认值说明
v-modelString-数据双向绑定
placeholderString-占位符
disabledBoolenfalse是否禁止
maxlengthNumber-1输入长度限制
clearableBooleanfalse是否显示一键清空按钮
isShowMapBooleanfalse是否显示地图预览
locationObject{}初始化地图中心点位置
scaleNumber14地图缩放等级
  • [ location ]结构
属性名类型默认值说明
latitudeString-纬度
longitudeString-经度

事件

事件名说明返回值
@location监听地址信息
  • [ @location ] 返回参数
属性名说明
name位置名称
address详细地址
latitude纬度,浮点数,范围为-90~90,负数表示南纬,使用 gcj02 国测局坐标系。
longitude经度,浮点数,范围为-180~180,负数表示西经,使用 gcj02 国测局坐标系。

Copyright © 2017 10yun.com | 十云提供计算服务-IPV6 | ctocode组开发