標籤:++ cat style 中間 ace img play 折線 nbsp
對於高德地圖也是一個新手,很多功能看文檔,問技術 或者高德群裡討論 群號:204668425
在我們需求中繪製的有 圓 折線 不規則圖形 方式,開啟地圖指定的繪製圖形置於螢幕中間
1、首先建立一個數組-- arraySpace
圓: 需要根據圓的半徑 中心點計算 垂直的四個
//加入所有圓的點//設定位置的點 CLLocationCoordinate2D destinationCoordinated =CLLocationCoordinate2DMake(latitude,longitude); MAPointAnnotation * a1= [[MAPointAnnotation alloc] init]; a1.coordinate =destinationCoordinated; // 111000 這個是米轉換經緯度的最大尺度,所以算出來的點只會在圓之外 double jingwei = (double) areaRadius/111000; //計入一個中心點 [arraySpace addObject:a1]; //由原點計算上下左右的四個點 for (int i=0; i<4; i++) { MAPointAnnotation * a1= [[MAPointAnnotation alloc] init]; switch (i) { case 0: NSLog(@"%lf----%lf",latitude+jingwei,longitude+jingwei); a1.coordinate = CLLocationCoordinate2DMake(latitude+jingwei,longitude); break; case 1: a1.coordinate = CLLocationCoordinate2DMake(latitude-jingwei,longitude); break; case 2: a1.coordinate = CLLocationCoordinate2DMake(latitude,longitude+jingwei); break; case 3: a1.coordinate = CLLocationCoordinate2DMake(latitude,longitude-jingwei); break; default: break; } //加入數組 [arraySpace addObject:a1]; }計算四個點
2、折線、多邊形 加入所有的點---》arraySpace
3、用下邊的方法 控制顯示在螢幕中的大小
以點的方式 添加
[self.mapView showAnnotations:self.arraySpace edgePadding:UIEdgeInsetsMake(200, 200, 350, 200) animated:YES];
以繪製 圖的方式添加
self.mapView showOverlays:<#(NSArray *)#> edgePadding:<#(UIEdgeInsets)#> animated:<#(BOOL)#>
iOS高德地圖讓指定地區或者點顯示在螢幕中間