如何放大并居中用户位置“点”?我已经尝试过在这里和其他网站上找到的所有内容,但我似乎无法做到正确。
请帮助我!
编辑:我试图在viewDidAppear中实现这行代码。我在一个旧的线程中找到了它,但它似乎不再起作用了......protected List<string> clickOrderList = new List<string>();
private void Form1_Load(object sender, EventArgs e)
{
// Populate the checked ListBox
this.checkedListBox1.Items.Add("Row1");
this.checkedListBox1.Items.Add("Row2");
this.checkedListBox1.Items.Add("Row3");
this.checkedListBox1.Items.Add("Row4");
}
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (sender != null && e != null)
{
// Get the checkListBox selected time and it's CheckState
CheckedListBox checkListBox = (CheckedListBox)sender;
string selectedItem = checkListBox.SelectedItem.ToString();
// If curent value was checked, then remove from list
if (e.CurrentValue == CheckState.Checked &&
clickOrderList.Contains(selectedItem))
{
clickOrderList.Remove(selectedItem);
}
// else if new value is checked, then add to list
else if (e.NewValue == CheckState.Checked &&
!clickOrderList.Contains(selectedItem))
{
clickOrderList.Insert(0, selectedItem);
}
}
}
private void ShowClickOrderButton_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
foreach (string s in clickOrderList)
{
sb.AppendLine(s);
}
MessageBox.Show(sb.ToString());
}
答案 0 :(得分:1)
我以编程方式创建了地图,而不是使用MapKit View,它完美无缺!
以下是代码:
[super viewDidLoad];
self.mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[self.mapView setShowsUserLocation:YES];
[self.mapView setDelegate:self];
[self.view addSubview:self.mapView];
[mapView setMapType:MKMapTypeHybrid];
}
#pragma mark - MKMapViewDelegate Methods
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
[self.mapView setRegion:MKCoordinateRegionMake(userLocation.coordinate, MKCoordinateSpanMake(0.1f, 0.1))animated:YES];
}
答案 1 :(得分:0)
您是否尝试过为地图设置区域,我列出了所有步骤,万一您错过了什么,让我知道您缺少哪些,我会提供代码。
viewDidLoad
或viewDidAppear
以适合您的流量为准。初始化地图并在didUpdateUserLocation
中监听位置更新后,您必须启动地图并挂钩更新位置,您需要像这样设置区域
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
//Mapview is your map on display,
CLLocationCoordinate2D coord = self.mapView.userLocation.coordinate;
//Create a region with a 1000x1000 meter around the user location
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(coord, 1000, 1000);
//Set the region of your mapview so the user location is in center and update
[self.mapView setRegion:viewRegion];
}