本文整理汇总了C#中Map.SetView方法的典型用法代码示例。如果您正苦于以下问题:C# Map.SetView方法的具体用法?C# Map.SetView怎么用?C# Map.SetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.SetView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
bikePaths = new BikePaths();
trees = Tree.ParseCsv();
map = new Map();
map.CredentialsProvider = new ApplicationIdCredentialsProvider("Atvj6eBBbDS6-dL7shp9KmzY-0v0NL2ETYCFoHIDzQwK8_9bJ2ZdRgeMAj0sDs_F");
// Set the center coordinate and zoom level
GeoCoordinate mapCenter = new GeoCoordinate(45.504693, -73.576494);
int zoom = 14;
// Create a pushpin to put at the center of the view
Pushpin pin1 = new Pushpin();
pin1.Location = mapCenter;
pin1.Content = "McGill University";
map.Children.Add(pin1);
bikePaths.AddPathsToMap(map);
// Set the map style to Aerial
map.Mode = new Microsoft.Phone.Controls.Maps.AerialMode();
// Set the view and put the map on the page
map.SetView(mapCenter, zoom);
ContentPanel.Children.Add(map);
}
示例2: OnGeocodeResultChanged
private static void OnGeocodeResultChanged(Map map, BingMapsService.GeocodeResult oldValue, BingMapsService.GeocodeResult newValue)
{
Location location = newValue.Locations.Select(x => new Location(x.Latitude, x.Longitude)).First();
Pushpin pin = new Pushpin();
pin.Location = location;
pin.ToolTip = newValue.Address.FormattedAddress;
var locationLayer = GetGeocodeResultLayer(map);
if (locationLayer == null)
{
locationLayer = new MapLayer();
SetGeocodeResultLayer(map, locationLayer);
}
locationLayer.Children.Clear();
locationLayer.Children.Add(pin);
map.SetView(location, map.ZoomLevel);
}
示例3: OnRouteQueryCompleted
private void OnRouteQueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
{
if (e.Error == null)
{
var geometry = e.Result.Legs[0].Geometry;
var start = geometry[0];
var end = geometry[geometry.Count - 1];
var center = new GeoCoordinate((start.Latitude + end.Latitude) / 2, (start.Longitude + end.Longitude) / 2);
var map = new Map
{
IsEnabled = false,
Center = center,
ZoomLevel = 20,
PedestrianFeaturesEnabled = true,
LandmarksEnabled = true,
};
map.Loaded += delegate
{
MapsSettings.ApplicationContext.ApplicationId = AppMetadata.Current.AppId.ToString("D");
MapsSettings.ApplicationContext.AuthenticationToken = AppMetadata.Current.MapAuthenticationToken;
};
var mapLayer = new MapLayer();
mapLayer.Add(new MapOverlay
{
GeoCoordinate = start,
PositionOrigin = new Point(0, 1),
Content = new Pushpin
{
Content = "Me",
}
});
mapLayer.Add(new MapOverlay
{
GeoCoordinate = end,
PositionOrigin = new Point(0, 1),
Content = new Pushpin
{
Content = departuresAndArrivalsTable.Station.Name + " Station",
}
});
map.Layers.Add(mapLayer);
map.AddRoute(new MapRoute(e.Result));
var pivotItem = new PivotItem
{
Header = "Directions",
Content = map
};
pivotItem.Tap += delegate
{
ErrorReporting.Log("OnMapClick");
new DirectionsRouteDestinationTask
{
Origin = start,
Destination = end,
Mode = RouteMode.Pedestrian,
}.Show();
};
pivot.Items.Add(pivotItem);
bool mapCentered = false;
pivot.SelectionChanged += delegate
{
if (!mapCentered && pivot.SelectedIndex == mapIndex)
{
map.SetView(e.Result.BoundingBox);
mapCentered = true;
}
};
}
}
示例4: SetCenterView
private static void SetCenterView(Map map, Location location)
{
map.SetView(location, 13, 0, MapAnimationDuration.Default);
}
示例5: createSettingsFlyout
private void createSettingsFlyout(SettingsFlyout sf, Gig g)
{
sf.HeaderText = g.title;
sf.FlyoutWidth = SettingsFlyout.SettingsFlyoutWidth.Wide;
StackPanel sp = new StackPanel() { Orientation = Orientation.Vertical };
#region Venue
sp.Children.Add(new TextBlock() { Text = "Venue", Style = this.Resources["HeaderStyle"] as Style });
if (g.venue.url != null)
{
HyperlinkButton hb = new HyperlinkButton();
hb.Content = g.venue.Title;
hb.Tag = g.venue.id;
hb.Style = this.Resources["HyperStyle"] as Style;
hb.Click+=hb_Click_Venue;
sp.Children.Add(hb);
}
else
{
sp.Children.Add(new TextBlock { Text = g.venue.Title, Style = this.Resources["ContentStyle"] as Style });
}
sp.Children.Add(new TextBlock() { Text = "Artists", Style = this.Resources["HeaderStyle"] as Style });
#endregion
#region Artists
StackPanel artistPanel = new StackPanel();
foreach (string s in g.artists.artist)
{
HyperlinkButton hb = new HyperlinkButton() { Content = s, Style = this.Resources["HyperStyle"] as Style };
hb.Click += hb_Click;
artistPanel.Children.Add(hb);
}
sp.Children.Add(artistPanel);
#endregion
#region Street
if (g.venue.location.street != "")
{
sp.Children.Add(new TextBlock() { Text = "Address", Style = this.Resources["HeaderStyle"] as Style });
sp.Children.Add(new TextBlock() { Text = g.venue.location.street, Style = this.Resources["ContentStyle"] as Style });
}
#endregion
#region City
sp.Children.Add(new TextBlock() { Text = "City", Style = this.Resources["HeaderStyle"] as Style });
sp.Children.Add(new TextBlock() { Text = g.venue.location.city, Style = this.Resources["ContentStyle"] as Style });
#endregion
#region Time
sp.Children.Add(new TextBlock() { Text = "Time", Style = this.Resources["HeaderStyle"] as Style });
sp.Children.Add(new TextBlock() { Text = g.startDate.Substring(0, g.startDate.Length-3), Style = this.Resources["ContentStyle"] as Style });
#endregion
sp.Children.Add(new TextBlock() { Text = "More Details", Style = this.Resources["HeaderStyle"] as Style });
sp.Children.Add(new HyperlinkButton() { Content = g.url, NavigateUri =new Uri( g.url), Style = this.Resources["HyperStyle"] as Style });
Map m = new Map();
m.Height = 400;
Pushpin p = new Pushpin();
MapLayer.SetPosition(p, new Location(double.Parse(g.venue.location.point.lat), double.Parse(g.venue.location.point.longt)));
m.Children.Add(p);
m.ZoomLevel = 15;
m.Credentials = MAPS_KEY;
m.ShowScaleBar = false;
m.ShowNavigationBar = false;
m.SetView(new Location(double.Parse(g.venue.location.point.lat), double.Parse(g.venue.location.point.longt)));
sp.Children.Add(m);
sf.ContentBackgroundBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
sf.Content = sp;
}
示例6: setMapToLastVisitedLocation
//We will use this method to set our map location on the ui
public void setMapToLastVisitedLocation(GeoCoordinate coordinates, Map MyMap)
{
//clear any markings on the map
MyMap.Layers.Clear();
//create a new layer to place on the map
MapLayer mapLayer = new MapLayer();
//check if coordinates have a value
if (coordinates != null)
{
DrawMapMarker(coordinates, Colors.Black, mapLayer);
}
//after marker is drawn add it to map layers
MyMap.Layers.Add(mapLayer);
MyMap.SetView(coordinates, 16);
}
示例7: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
LocationAssistant.Instance.WalkingPositionChanged += OnWalkingPositionChanged;
_map = new Map();
_map.ScaleVisibility = System.Windows.Visibility.Visible;
_map.CopyrightVisibility = System.Windows.Visibility.Collapsed;
LayoutRoot.Children.Add(_map);
_map.MapZoom += _map_MapZoom;
_map.MapResolved += _map_MapResolved;
_map.MapPan += _map_MapPan;
IAppInfo iai = Application.Current as IAppInfo;
if (iai != null)
{
_map.CredentialsProvider = new ApplicationIdCredentialsProvider(iai.BKey);
}
if (_layer != null && _map.Children.Contains(_layer))
{
_map.Children.Remove(_layer);
_layer = null;
}
_layer = new MapLayer();
_map.Children.Add(_layer);
var loc = LocationAssistant.Instance.LastKnownLocation.AsGeoCoordinate();
_map.SetView(loc, 14);
if (_gpsPushpin == null)
{
_gpsPushpin = new Pushpin();
_gpsPushpin.Location = LocationAssistant.Instance.LastKnownLocation.AsGeoCoordinate();
var cs = LayoutRoot.Resources["MePushpinStyle"] as Style;
_gpsPushpin.Style = cs;
_layer.Children.Add(_gpsPushpin);
}
if (Environment.OSVersion.Version.Minor >= 1)
{
// mango hack
var st = typeof(SystemTray);
var opacity = st.GetProperty("Opacity");
if (opacity != null)
{
opacity.SetValue(null, 0.65, null);
SystemTray.IsVisible = true;
}
}
//SetupAppBar();
if (_checkins != null)
{
Update(_checkins);
}
else
{
_checkins = DataManager.Current.Load<Checkins>("Checkins", OnCompleted, OnError);
}
}
示例8: GetDirections
public static async void GetDirections(Map myMap, Border RouteResults)
{
MapShapeLayer routeLayer = new MapShapeLayer();
myMap.ShapeLayers.Add(routeLayer);
Uri routeRequest = new Uri(string.Format(
"http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0={0},{1}&wp.1={2},{3}&rpo=Points&key={4}", staticObjects.CurrentLatitude, staticObjects.CurrentLongitude, staticObjects.GoalLatitude, staticObjects.GoalLongitude, myMap.Credentials));
//Make a request and get the response
Response r = await GetResponse(routeRequest);
if (r != null &&
r.ResourceSets != null &&
r.ResourceSets.Length > 0 &&
r.ResourceSets[0].Resources != null &&
r.ResourceSets[0].Resources.Length > 0)
{
Route route = r.ResourceSets[0].Resources[0] as Route;
//Get the route line data
double[][] routePath = route.RoutePath.Line.Coordinates;
LocationCollection locations = new LocationCollection();
for (int i = 0; i < routePath.Length; i++)
{
if (routePath[i].Length >= 2)
{
locations.Add(new Bing.Maps.Location(routePath[i][0],
routePath[i][1]));
}
}
MapPolyline routeLine = new MapPolyline()
{
Color = Colors.Indigo,
Locations = locations,
Width = 7
};
routeLayer.Shapes.Add(routeLine);
BitmapImage srcStart = new BitmapImage();
srcStart.UriSource = new Uri(App.fbProfilePicture, UriKind.Absolute);
ImageBrush imgStart = new ImageBrush();
imgStart.ImageSource = srcStart;
Ellipse start = new Ellipse() { Fill = imgStart, Height = 70, Width = 70 };
myMap.Children.Add(start);
MapLayer.SetPosition(start,
new Bing.Maps.Location(route.RouteLegs[0].ActualStart.Coordinates[0],
route.RouteLegs[0].ActualStart.Coordinates[1]));
BitmapImage srcEnd = new BitmapImage();
srcEnd.UriSource = staticObjects.FriendProfilePicture;
ImageBrush imgEnd = new ImageBrush();
imgEnd.ImageSource = srcEnd;
Ellipse end = new Ellipse() { Fill = imgEnd, Height = 70, Width = 70 };
myMap.Children.Add(end);
MapLayer.SetPosition(end,
new Bing.Maps.Location(route.RouteLegs[0].ActualEnd.Coordinates[0],
route.RouteLegs[0].ActualEnd.Coordinates[1]));
myMap.SetView(new LocationRect(locations));
RouteResults.DataContext = route;
}
}