1. 8.地图新增缩放等级
1.1.1. 十四、地图新增缩放等级
第1步:修改地图协议
public protocol MapViewProtocol: NSObjectProtocol {
......
var zoomLevel: CGFloat { get set }
var minZoomLevel: CGFloat { get set }
var maxZoomLevel: CGFloat { get set }
}
第2步:修改地图实现
高德地图
class GaodeMapView: NSObject, MapViewProtocol {
......
var zoomLevel: CGFloat {
get {
mapView.zoomLevel
}
set {
mapView.zoomLevel = newValue
}
}
var minZoomLevel: CGFloat {
get {
mapView.minZoomLevel
}
set {
mapView.minZoomLevel = newValue
}
}
var maxZoomLevel: CGFloat {
get {
mapView.maxZoomLevel
}
set {
mapView.maxZoomLevel = newValue
}
}
}
百度地图
class BaiduMapView: NSObject, MapViewProtocol {
......
var zoomLevel: CGFloat {
get {
CGFloat(mapView.zoomLevel)
}
set {
mapView.zoomLevel = Float(newValue)
}
}
var minZoomLevel: CGFloat {
get {
CGFloat(mapView.minZoomLevel)
}
set {
mapView.minZoomLevel = Float(newValue)
}
}
var maxZoomLevel: CGFloat {
get {
CGFloat(mapView.maxZoomLevel)
}
set {
mapView.maxZoomLevel = Float(newValue)
}
}
}