Exemple #1
0
        public void AddLandmarkPhoto()
        {
            // Create MapBillboard.

            BasicGeoposition cityPosition = new BasicGeoposition()
            {
                Latitude = 55.6509863734914, Longitude = 37.6680877307923, Altitude = 0
            };

            SeattleLocation1 = new Geopoint(cityPosition);
            Geopoint cityCenter = new Geopoint(cityPosition);

            var mapBillboard = new MapBillboard(MapControl1.ActualCamera)
            {
                Location = cityCenter,
                NormalizedAnchorPoint = new Point(0.5, 1.0),
            };

            // Add MapBillboard to a layer on the map control.

            var MyLandmarkPhotos = new List <MapElement>();

            MyLandmarkPhotos.Add(mapBillboard);

            var LandmarksPhotoLayer = new MapElementsLayer
            {
                ZIndex      = 1,
                MapElements = MyLandmarkPhotos
            };

            MapControl1.Layers.Add(LandmarksPhotoLayer);
        }
Exemple #2
0
        /// <summary>
        /// This method will create a new billboard at the center of the map with the current camera as reference
        /// </summary>
        private void mapBillboardAddButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // MapBillboard scales with respect to the perspective projection of the 3D camera.
            // The reference camera determines at what view distance the billboard image appears at 1x scale.
            MapBillboard mapBillboard = new MapBillboard(myMap.ActualCamera);

            mapBillboard.Location = myMap.Center;
            mapBillboard.NormalizedAnchorPoint = new Point(0.5, 1.0);
            mapBillboard.Image = mapBillboardStreamReference;
            myMap.MapElements.Add(mapBillboard);
        }
        // Funtion to add Image overlay to MapControl. Zoom level is very important when inserting picture overlay, as it determines the size and location of overlay.
        // It corespond with actual view on the map. The change view method of Bing maps is Async, making it difficult to place image correctly.
        public async Task <int> AddMapOverlayAsync(Double latitude, Double longtitude, Uri img)
        {
            // Defining position for image overlay. Map View ZoomLevel defines the images size relative to map
            Geopoint position = new Geopoint(new BasicGeoposition()
            {
                Latitude  = latitude,
                Longitude = longtitude,
                Altitude  = 0
            }, AltitudeReferenceSystem.Surface);

            //Making sure the view ZoomLevel is correct for inserting image as overlay.
            while (gmitMap.ZoomLevel < 18.9)
            {
                await gmitMap.TrySetViewAsync(gmit, 19D, 0, 0);

                await Task.Delay(1000);

                Debug.WriteLine(gmitMap.ZoomLevel);
            }
            // Create MapBillboard Image.
            RandomAccessStreamReference imgStream =
                RandomAccessStreamReference.CreateFromUri(img);
            var mapBillboard = new MapBillboard(gmitMap.ActualCamera)
            {
                Location = position,
                NormalizedAnchorPoint = new Point(0D, 0D),
                Image = imgStream,
            };
            int index         = gmitMap.Layers.Count;
            var GmitFloorMaps = new List <MapElement>
            {
                mapBillboard
            };
            var LandmarksPhotoLayer = new MapElementsLayer
            {
                ZIndex      = 0,
                MapElements = GmitFloorMaps,
                Visible     = false
            };

            // Image is added as an new Layer to MapControl. ZIndex must be 0, so Icon with Zindex 1 will be on top of overlay.
            gmitMap.Layers.Add(LandmarksPhotoLayer);
            return(index);
        }