在carouselView地图中显示路线时,我遇到了问题。
设置
我的VireModel中的carouselview绑定到了一个cotentview
private ContentView carousel;
public ContentView Carousel
{
get { return carousel; }
set
{
if (carousel != value)
{
carousel = value;
OnPropertyChanged("Carousel");
}
}
}我给它以下的contentViews作为项目
private void InitializeCarousel()
{
Carousel = new ContentView()
{
Content = CarouselView()
};
}
private CarouselView CarouselView()
{
ContentView[] items = CarouselItems();
CarouselView carouselView = new CarouselView()
{
ItemsSource = items,
IndicatorView = indicatorView,
ItemTemplate = viewDataTemplate
};
return carouselView;
}
private ContentView[] CarouselItems()
{
ContentView[] items = new ContentView[5]
{
MapView(), SpeedView(), PaceView(), HeightView(), StepLengthView()
};
return items;
}MapView()的实现方式如下:
private ContentView MapView()
{
Polygon route = new Polygon
{
StrokeWidth = 8,
StrokeColor = Color.FromHex("#1BA1E2"),
Geopath =
{
new Position(47.6368678, -122.137305),
new Position(47.6368894, -122.134655),
new Position(47.6359424, -122.134655),
new Position(47.6359496, -122.1325521),
new Position(47.6424124, -122.1325199),
new Position(47.642463, -122.1338932),
new Position(47.6406414, -122.1344833),
new Position(47.6384943, -122.1361248),
new Position(47.6372943, -122.1376912)
}
};
MapSpan span = new MapSpan(new Position(47.6368678, -122.137305), 0.02, 0.02);
Map map = new Map(span)
{
HasScrollEnabled = false,
HasZoomEnabled = false,
};
map.MapElements.Add(route);
ContentView view = new ContentView()
{
Content = map
};
return view;
}问题
问题是,如果在应用程序中打开页面,地图就会完全放大。如果我按时滑过旋转木马,我就能看到路线,MapSpan也是正确的。


编辑
这里有一个问题

发布于 2021-03-05 12:17:30
请在您的map.MoveToRegion(mapSpan);方法中添加MapView。
private ContentView MapView()
{
Polygon route = new Polygon
{
StrokeWidth = 8,
StrokeColor = Color.FromHex("#1BA1E2"),
Geopath =
{
new Position(47.6368678, -122.137305),
new Position(47.6368894, -122.134655),
new Position(47.6359424, -122.134655),
new Position(47.6359496, -122.1325521),
new Position(47.6424124, -122.1325199),
new Position(47.642463, -122.1338932),
new Position(47.6406414, -122.1344833),
new Position(47.6384943, -122.1361248),
new Position(47.6372943, -122.1376912)
}
};
MapSpan span = new MapSpan(new Position(47.6368678, -122.137305), 0.02, 0.02);
Map map = new Map(span)
{
HasScrollEnabled = false,
HasZoomEnabled = false,
};
map.MapElements.Add(route);
ContentView view = new ContentView()
{
Content = map
};
map.MoveToRegion(mapSpan);
return view;
}https://stackoverflow.com/questions/66492177
复制相似问题