我试图找出如何使用SWIFT在IOS地图上叠加图像.我创建了以下代码,使用地图工具包覆盖地图上的绿色圆圈.我想用矩形图像替换绿色圆圈tOver.png 500,500我是iOS开发新手并且很快.到目前为止,我找不到一个快速的例子或好的资源.
//
// ViewController.swift
// mapoverlaytest
//
import UIKit
import MapKit
class ViewController: UIViewController,MKMapViewDelegate {
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
self.mapView.delegate = self;
let location = CLLocationCoordinate2D(
latitude: 51.50007773,
longitude: -0.1246402
)
let span = MKCoordinateSpanMake(0.05, 0.05)
let region = MKCoordinateRegion(center: location, span: span)
mapView.setRegion(region, animated: true)
let annotation = MKPointAnnotation()
annotation.setCoordinate(location)
annotation.title = "Big Ben"
annotation.subtitle = "London"
var overlay = MKCircle (centerCoordinate: location, radius: 500)
mapView.addOverlay(overlay)
mapView.addAnnotation(annotation)
}
func mapView(
mapView: MKMapView!, …Run Code Online (Sandbox Code Playgroud)