当前位置:网站首页>SwiftUI 地图大全之 使用 MapKit 进行搜索
SwiftUI 地图大全之 使用 MapKit 进行搜索
2022-07-27 12:52:00 【知识大胖】
搜索地点是我们在应用程序中可能需要的一个有趣的功能。让我们用 SwiftUI 开发这个功能。
首先,让我们创建一个视图模型,其中包含一个确认 Observable 对象的类。此类具有发布搜索结果的 searchResults 变量。LocationManager 向“MKLocalSearchCompleterDelegate”确认,后者通过“completerDidUpdateResults”提供搜索结果。
class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate, MKLocalSearchCompleterDelegate {
let manager = CLLocationManager()
@Published var region: MKCoordinateRegion
@Published var location: CLLocationCoordinate2D?
@Published var name: String = ""
@Published var search: String = ""
@Published var searchResults = [MKLocalSearchCompletion]()
var publisher: AnyCancellable?
var searchCompleter = MKLocalSearchCompleter()
override init() {
let latitude = 0
let longitude = 0
self.region = MKCoordinateRegion(center:CLLocationCoordinate2D(latitude:
边栏推荐
- 52:第五章:开发admin管理服务:5:开发【分页查询admin账号列表,接口】;(Swagger的@ApiParam(),对方法参数进行注释;PageHelper分页插件;拦截器拦截检查登录状态)
- Feign's dynamic proxy
- 【C语言入门】ZZULIOJ 1021-1025
- Li Hang, director of ByteDance AI Lab: past, present and future of language model
- 电气成套企业如何借助ERP系统,做好成本利润管理?
- Data enhancement in image processing
- Fiddler抓包工具+夜神模拟器
- 7.26 simulation summary
- Text style
- Training in the second week of summer vacation on July 24, 2022
猜你喜欢

Seata's landing practice in ant International Banking

纵横靶场-图片的奥秘

附加:【URLEncoder.encode(待编码字符串, “编码方式“);】(是什么?;我们向cookie中设置值的时候,为什么要使用这个去编码?)(待完善……)

以科技传递温度,vivo亮相数字中国建设峰会

What are the precautions for using carbon brushes

Set up SSH key based authentication using putty

Vertical and horizontal shooting range - the mystery of the picture

剑指Offer 07 重建二叉树 -- 从中序与后序遍历序列构造二叉树
![51: Chapter 5: develop admin management services: 4: develop [add admin account, interface]; (only [user name + password, method]; [@t...] annotation controls transactions; when setting cookies, do yo](/img/6f/4f93eca1d923a58b2ef4b1947538be.png)
51: Chapter 5: develop admin management services: 4: develop [add admin account, interface]; (only [user name + password, method]; [@t...] annotation controls transactions; when setting cookies, do yo

面试官常问:如何手撸一个“消息队列”和“延迟消息队列”?
随机推荐
Product manager experience 100 (XI) - Strategic Product Manager: model and methodology
Relative positioning
期货公司开户后续会有哪些服务?
How about the strength of database HTAP
Construction and application of industrial knowledge atlas (2): representation and modeling of commodity knowledge
The role of Clearfix
uniapp防止连续点击出错
Creation and destruction of "C language" function stack frame -- (internal skill)
Redis总结:缓存雪崩、缓存击穿、缓存穿透与缓存预热、缓存降级
Training in the second week of summer vacation on July 24, 2022
Design of network abnormal traffic analysis system
SNMP (Simple Network Management Protocol)
Preliminary discussion on NetGen and Gmsh mesh generation of any multiple sub models of CAD based on osg+occ
SCI论文写作
V-on basic instruction
libevent 之 evconnlistener_new_bind
Keras深度学习实战——推荐系统数据编码
图像特征及提取
Set up SSH key based authentication using putty
Seata 在蚂蚁国际银行业务的落地实践