Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Basit Harita ve Kendi Konumunu Görme Uygulaması Örneği | Swift ---
// TabKonumViewController.swift
// Bildir-Basic
// Created by Bülent Siyah on 12.05.2018.
// Copyright © 2018 Bülent Siyah. All rights reserved.
import UIKit
import MapKit
import CoreLocation
import CoreData
class TabKonumViewController: UIViewController , MKMapViewDelegate, CLLocationManagerDelegate{
@IBOutlet weak var map: MKMapView!
var locationManager = CLLocationManager()
var requestCLLocation = CLLocation()
override func viewDidLoad() {
map.delegate = self
locationManager.delegate = self
//best olursa fazla batarya tüketimi olur
locationManager.desiredAccuracy = kCLLocationAccuracyBest
//kullanıcı sadece uygulama açıkken konum takibi yapar
locationManager.startUpdatingLocation() = true
override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.
override func viewWillAppear(_ animated: Bool) {
var lat = StaticObject.detayNotificationn.Latitude!
var lon = StaticObject.detayNotificationn.Longitude!
let location = CLLocationCoordinate2D(latitude: CLLocationDegrees(lat), longitude: CLLocationDegrees(lon))
let span = MKCoordinateSpan(latitudeDelta: 0.000750, longitudeDelta: 0.000750)
let region = MKCoordinateRegion(center: location, span: span)
map.setRegion(region, animated: true)
let annotation = MKPointAnnotation()
let coordinate = CLLocationCoordinate2D(latitude: lat, longitude: lon)
annotation.coordinate = coordinate
annotation.title = "#" + StaticObject.detayNotificationn.No!
annotation.subtitle = StaticObject.detayNotificationn.BilgilendirAdiSoyadi
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = CLLocationCoordinate2D(latitude: locations[0].coordinate.latitude, longitude: locations[0].coordinate.longitude)
let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)
let region = MKCoordinateRegion(center: location, span: span)
//map.setRegion(region, animated: true)
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment