当前位置: 首页>>代码示例>>C#>>正文


C# Map.SetView方法代码示例

本文整理汇总了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);
        }
开发者ID:TryCatch22,项目名称:Project-Beaver,代码行数:30,代码来源:MainPage.xaml.cs

示例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);
        }
开发者ID:Neeelsie,项目名称:REII422_DesktopApp,代码行数:20,代码来源:MapInteractivity.cs

示例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;
                    }
                };
            }
        }
开发者ID:ruze00,项目名称:Apps,代码行数:71,代码来源:StationPage.xaml.cs

示例4: SetCenterView

 private static void SetCenterView(Map map, Location location)
 {
     map.SetView(location, 13, 0, MapAnimationDuration.Default);
 }
开发者ID:hvining,项目名称:MeetupTestApp,代码行数:4,代码来源:MapMonitorBehavior.cs

示例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;
        }
开发者ID:abettadapur,项目名称:LastFMEvents,代码行数:73,代码来源:ArtistDetailPage.xaml.cs

示例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);

        }
开发者ID:javierb13,项目名称:foursquare,代码行数:20,代码来源:MainPage.xaml.cs

示例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);
            }
        }
开发者ID:TediWang,项目名称:4thandmayor-ancient,代码行数:64,代码来源:NearbyFriendsMap.xaml.cs

示例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;
            }
        }
开发者ID:JorgeCupi,项目名称:SmartGuard,代码行数:67,代码来源:UsefulCrap.cs


注:本文中的Map.SetView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。