嗨,我是開發Map-view Base應用程序的人。我差不多已經完成了所有的map-view,但我無法比較兩個不同的地圖視圖區域並找到新的地圖視圖區域。例如,如果用戶拖動地圖,我想查找該地區發生了多大變化。如何比較兩個不同的地圖視圖區域,並找出它們之間的區別
0
A
回答
-1
這個答案告訴你如何比較兩個地圖點。你可以在地圖區域的中心使用它:link。
0
首先你需要找到初始地圖區域。說你的地圖被命名爲MapView的......你可以先通過(在viewDidLoad中)找到此:
CLLocationCoordinate2D center = mapView.centerCoordinate;
CLLocationDegrees lat = center.latitude;
CLLocationDegrees lon = center.longitude;
MKCoordinateRegion region = mapView.region;
MKCoordinateSpan span = region.span;
//Assuming they have been declared as instance variables of type double
current_lat_low = lat - span.latitudeDelta/2.0;
current_lat_high = lat + span.latitudeDelta/2.0;
current_lon_low = lon - span.longitudeDelta/2.0;
current_lon_high = lon + span.longitudeDelta/2.0;
這會給你顯示的地圖的初始區域。然後在
- (void)mapView:(MKMapView*)mapView regionDidChangeAnimated:(BOOL)animated
{
CLLocationCoordinate2D center = mapView.centerCoordinate;
CLLocationDegrees lat = center.latitude;
CLLocationDegrees lon = center.longitude;
MKCoordinateRegion region = mapView.region;
MKCoordinateSpan span = region.span;
double lat_low = lat - span.latitudeDelta/2.0;
double lat_high = lat + span.latitudeDelta/2.0;
double lon_low = lon - span.longitudeDelta/2.0;
double lon_high = lon + span.longitudeDelta/2.0;
//do any work comparing the initial lat/lons with the new values
.....
//set current lat/lon to be the new lat/lon after work is complete
current_lat_low = lat_low;
current_lat_high = lat_high;
current_lon_low = lon_low;
current_lon_high = lon_high;
}
相關問題
- 1. 如何比較日期並給出它們之間的區別?
- 2. 如何比較兩個MySQL表並打印它們之間的區別?
- 3. 如何比較兩個visio文件並報告它們之間的區別?
- 4. jQuery比較並找出2個json數組之間的區別
- 5. 查找兩個圖像之間的不同區域
- 6. 兩張地圖之間的區別
- 7. 如何比較兩個列表並找出它們之間的差異?
- 8. 如何找到兩個圖像之間的區別?
- 9. Rails:TimeWithZone比較不同區域的時間
- 10. 如何獲得兩個地圖Java之間的區別?
- 11. 任何方式來比較兩個不同的位圖圖像,並檢測到JavaScript中的不同區域?
- 12. 比較兩個字符串,並採取以百分比它們之間的區別(PHP)
- 13. 是否可以比較mapview的兩個不同區域並找到差異?
- 14. 我們如何製作地圖視圖區域的數組?
- 15. 視圖和tableViewControllers之間的UIBarButton區別?
- 16. 如何比較不同時區之間的時間戳?
- 17. 地圖和ImmutableMap之間的區別
- 18. 地圖和字典之間的區別
- 19. 比較兩個文本,並突出唯一的區別
- 20. SQL - JOIN和比較不同表中的兩行之間的區別是什麼?
- 21. 谷歌地圖地圖API和Google地圖時區API之間的區別
- 22. 查找表中作爲列兩個領域之間的區別
- 23. 比較兩個畫布的區別
- 24. 比較兩幅圖像特定區域的直方圖? OpenCV
- 25. 如何找到android中的兩個區域之間的距離
- 26. 如何同時突出顯示地圖上的多個區域
- 27. 找到前兩排之間的區別
- 28. 類區域和堆之間的區別
- 29. 如何比較兩個表並顯示每一區別
- 30. AForge.net - BlobCounter獲取2個圖像之間的不同「區域」
感謝您重新申請。 – Nit 2012-02-03 05:42:10
這不是對兩個點之間的距離而不是兩個區域之間的距離進行比較的問題的答案。 – 2014-08-20 08:14:53