iOS高德地圖讓指定地區或者點顯示在螢幕中間

來源:互聯網
上載者:User

標籤:++   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高德地圖讓指定地區或者點顯示在螢幕中間

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.