Skip to content

CityLocate City Selector

City selection infrastructure for travel/e-commerce applications. Supports GPS location, hot cities, alphabet index, pinyin search, and recent visit cache.

Basic Usage

vue
<template>
  <see-city-locate @on-select="onSelect" />
</template>

<script setup>
const onSelect = (city) => {
  console.log('Selected:', city)
}
</script>

Custom Hot Cities

vue
<template>
  <see-city-locate :hot-cities="hotCities" @on-select="onSelect" />
</template>

<script setup>
const hotCities = [
  { id: 'beijing', name: 'Beijing', level: 'city' },
  { id: 'shanghai', name: 'Shanghai', level: 'city' }
]
</script>

CityInfo

PropertyTypeDescription
idstring | numberCity ID
namestringCity name
nameEnstringEnglish name
pinyinstringPinyin
firstLetterstringFirst letter
level'country' | 'province' | 'city' | 'district'Level
latitudenumberLatitude
longitudenumberLongitude
hotbooleanWhether hot city

Props

PropertyTypeDefaultDescription
modelValueCityInfo | nullnullSelected city
hotCitiesCityInfo[]Built-in hot citiesHot city list
citiesCityInfo[]Built-in city dataCity data list
isShowSearchbooleantrueWhether to show search box
isShowLocationbooleantrueWhether to show location
isShowHistorybooleantrueWhether to show recent visits
isInternationalbooleanfalseWhether international cities
maxHistorynumber10Max recent visits
searchPlaceholderstring'Search city'Search placeholder
locateTextstring'Locating...'Locate button text

Events

EventParametersDescription
onSelectcityCity selected
onLocatecityLocation success
onLocateErrorerrorLocation failed

Liao ICP No. 2025070134