Answer the question
In order to leave comments, you need to log in
Swift how to display current location in yandex map?
I get and show the current location on the map:
mapView.mapWindow.map.isRotateGesturesEnabled = false
mapView.mapWindow.map.move(with:
YMKCameraPosition(target: YMKPoint(latitude: 0, longitude: 0), zoom: 14, azimuth: 0, tilt: 0))
let scale = UIScreen.main.scale
let userLocationLayer = mapView.mapWindow.map.userLocationLayer
userLocationLayer.isEnabled = true
userLocationLayer.isHeadingEnabled = true
userLocationLayer.setAnchorWithAnchorNormal(
CGPoint(x: 0.5 * mapView.frame.size.width * scale, y: 0.5 * mapView.frame.size.height * scale),
anchorCourse: CGPoint(x: 0.5 * mapView.frame.size.width * scale, y: 0.83 * mapView.frame.size.height * scale))
userLocationLayer.setObjectListenerWith(self)
func onObjectAdded(with view: YMKUserLocationView) {
view.arrow.setIconWith(UIImage(named:"userArrow")!)
let pinPlacemark = view.pin.useCompositeIcon()
pinPlacemark.setIconWithName("icon",
image: UIImage(named:"Icon")!,
style:YMKIconStyle(
anchor: CGPoint(x: 0, y: 0) as NSValue,
rotationType:YMKRotationType.rotate.rawValue as NSNumber,
zIndex: 0,
flat: true,
visible: true,
scale: 1.5,
tappableArea: nil))
pinPlacemark.setIconWithName(
"pin",
image: UIImage(named:"SearchResult")!,
style:YMKIconStyle(
anchor: CGPoint(x: 0.5, y: 0.5) as NSValue,
rotationType:YMKRotationType.rotate.rawValue as NSNumber,
zIndex: 1,
flat: true,
visible: true,
scale: 1,
tappableArea: nil))
view.accuracyCircle.fillColor = UIColor.blue
}
func onObjectRemoved(with view: YMKUserLocationView) {}
func onObjectUpdated(with view: YMKUserLocationView, event: YMKObjectEvent) {
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question