Пример #1
1
        private void showlocations()
        {
            foreach (Place p in _vm.Places)
            {
                Grid MyGrid = new Grid();
                MyGrid.RowDefinitions.Add(new RowDefinition());
                MyGrid.RowDefinitions.Add(new RowDefinition());
                MyGrid.Background = new SolidColorBrush(Colors.Transparent);

                BitmapImage bmi = new BitmapImage(new Uri("/Assets/pushpinPhone.png", UriKind.Relative));
                Image img = new Image();
                img.Tag = (p);
                img.Source = bmi;
               
        
                MyGrid.Children.Add(img);


                //Creating a MapOverlay and adding the Grid to it.
                MapOverlay MyOverlay = new MapOverlay();
                MyOverlay.Content = MyGrid;

                MyOverlay.GeoCoordinate = new GeoCoordinate(p.Latitude, p.Longitude);


                MyOverlay.PositionOrigin = new Point(0, 0.5);

                //Creating a MapLayer and adding the MapOverlay to it
                MapLayer MyLayer = new MapLayer();
                MyLayer.Add(MyOverlay);
                mapWithMyLocation.Layers.Add(MyLayer);
            }
        }
Пример #2
0
        private async void ShowMyLocationOnTheMap()
        {
            // Get my current location.
            Geolocator myGeolocator = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
            Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
            GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();
            myCircle.Fill = new SolidColorBrush(Colors.Blue);
            myCircle.Height = 20;
            myCircle.Width = 20;
            myCircle.Opacity = 50;

            // Create a MapOverlay to contain the circle.
            MapOverlay myLocationOverlay = new MapOverlay();
            myLocationOverlay.Content = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate = myGeoCoordinate;

            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();
            myLocationLayer.Add(myLocationOverlay);

            // Add the MapLayer to the Map.
            Haritam.Layers.Add(myLocationLayer);
        }
Пример #3
0
        private void GeoButton_Click(object sender, RoutedEventArgs e)
        {
            if (markerLayer != null)
            {
                map1.Layers.Remove(markerLayer);
                markerLayer = null;
            }

            markerLayer = new MapLayer();
            map1.Layers.Add(markerLayer);

            if (geoQ.IsBusy == true){
                geoQ.CancelAsync();
            }
            // Set the full address query

            GeoCoordinate setMe = new GeoCoordinate(map1.Center.Latitude, map1.Center.Longitude);
            setMe.HorizontalAccuracy = 1000000;

            geoQ.GeoCoordinate = setMe;
            geoQ.SearchTerm = geoBox.Text;
            geoQ.MaxResultCount = 200;

            geoQ.QueryAsync();
            Debug.WriteLine("GeocodeAsync started for: " + geoBox.Text);
        }
Пример #4
0
 void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         Position item = lstPositions.Items.Last() as Position;
         location = new GeoCoordinate(item.Latitude, item.Longitude);
         mapPositions.Center = location;
         layer = new MapLayer();
         grid = new Grid();
         grid.DataContext = item;
         grid.Hold += grid_Hold;
         textBlock = new TextBlock();
         textBlock.Text = item.Counter.ToString();
         textBlock.VerticalAlignment = VerticalAlignment.Bottom;
         textBlock.HorizontalAlignment = HorizontalAlignment.Center;
         brush = new ImageBrush();
         brush.ImageSource = image;
         ellipse = new Ellipse();
         ellipse.Height = 100;
         ellipse.Width = 100;
         ellipse.Fill = brush;
         grid.Children.Add(ellipse);
         grid.Children.Add(textBlock);
         overlay = new MapOverlay();
         overlay.Content = grid;
         overlay.GeoCoordinate = location;
         layer.Add(overlay);
         mapPositions.Layers.Add(layer);
     }
 }
        private void StartCurrentPosition()
        {
            _progressIndicator.IsIndeterminate = true;

            _customLayer = new MapLayer();
            MapControl.Layers.Add(_customLayer);
            MapControl.Center = new GeoCoordinate(48.8607, 2.3504);
            MapControl.ZoomLevel = 10;

            Random rand = new Random();
            
            foreach (var evt in model.ItemsByDate)
            {
                MapIcon posIcon = new MapIcon()
                {
                    Width = 40,
                    Height = 40,
                    AnchorPoint = MapIconAnchorPoint.Center,
                    Coordinate = new GeoCoordinate(evt.loc[0], evt.loc[1]),
                    Source = new Uri("/PanoramaApp1;component/Images/MapObjects.png", UriKind.RelativeOrAbsolute),
                    Content =  GetPushPinTemplate( evt.text + " - " + evt.nb_plus, evt)
                };
                _customLayer.Children.Add(posIcon);
            }

            _progressIndicator.IsIndeterminate = false;
        }
Пример #6
0
        private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
        {
            if (e.Action == 1)
            {
                Position item = lstPositions.Items.Last() as Position;
                layers = new MapLayer();
                image = new BitmapImage();
                image.UriSource = (new Uri(SelectedFriend.Picture, UriKind.Absolute));

                grid = new Grid();
                grid.DataContext = item;
                grid.RightTapped += grid_RightTapped;
                textBlock = new TextBlock();
                textBlock.Text = item.Counter.ToString();
                textBlock.VerticalAlignment = VerticalAlignment.Bottom;
                textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                brush = new ImageBrush();
                brush.ImageSource = image;
                ellipse = new Ellipse();
                ellipse.Height = 100;
                ellipse.Width = 100;
                ellipse.Fill = brush;
                grid.Children.Add(ellipse);
                grid.Children.Add(textBlock);
                layers.Children.Add(grid);
                MapLayer.SetPosition(grid, new Location(item.Latitude, item.Longitude));
                myMap.Children.Add(layers);
            }
        }
Пример #7
0
        private async void ShowMyLocationOnTheMap()
        {
            // Get my current location.
            Geolocator myGeolocator = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
            Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
            GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            // Make my current location the center of the Map.
            this.mapWithMyLocation.Center = myGeoCoordinate;
            this.mapWithMyLocation.ZoomLevel = 13;

            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();
            myCircle.Fill = new SolidColorBrush(Colors.Red);
            myCircle.Height = 20;
            myCircle.Width = 20;
            myCircle.Opacity = 50;

            // Create a MapOverlay to contain the circle.
            MapOverlay myLocationOverlay = new MapOverlay();
            myLocationOverlay.Content = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate = myGeoCoordinate;

            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();
            myLocationLayer.Add(myLocationOverlay);

            // Add the MapLayer to the Map.
            mapWithMyLocation.Layers.Add(myLocationLayer);

            txTop.Text = ("My Location - Lat " + myGeoCoordinate.Latitude.ToString("0.0000") + "   Lon " + myGeoCoordinate.Longitude.ToString("0.0000"));
        }
Пример #8
0
        private async void ShowMyLocationOnTheMap()
        {
            Geolocator myGeolocator = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
            Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
            GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            this.BettingMap.Center = myGeoCoordinate;
            this.BettingMap.ZoomLevel = 15;

            Ellipse myCircle = new Ellipse();
            myCircle.Fill = new SolidColorBrush(Colors.Blue);
            myCircle.Height = 20;
            myCircle.Width = 20;
            myCircle.Opacity = 50;

            MapOverlay myLocationOverlay = new MapOverlay();
            myLocationOverlay.Content = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate = myGeoCoordinate;

            MapLayer myLocationLayer = new MapLayer();
            myLocationLayer.Add(myLocationOverlay);

            BettingMap.Layers.Add(myLocationLayer);
        }
        void CustomMapControl_Loaded( object sender, RoutedEventArgs e )
        {
            // initialize image overlay layer
             imageLayer = new MapLayer();
             map.Children.Add(imageLayer);

             // setup map control
             try {
            Settings.IsoManager.Instance.Load();
            map.SetView(
               Settings.IsoManager.Instance.MapSettings.Coordinate,
               Settings.IsoManager.Instance.MapSettings.ZoomLevel
               );
             }
             catch (Exception) { }

             // activate geo location watcher
             if (watcher == null) {
            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            watcher.MovementThreshold = 1.0;
            watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
            watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);

            if (!watcher.TryStart(true, TimeSpan.FromSeconds(5))) {
               MessageBox.Show("Please enable Location Service on the Phone.", "Warning", MessageBoxButton.OK);
            }
             }
        }
Пример #10
0
        private void AddPoint(Map controlMap, GeoCoordinate geo)
        {
            // With the new Map control:
            //  Map -> MapLayer -> MapOverlay -> UIElements
            //  - Add a MapLayer to the Map
            //  - Add an MapOverlay to that layer
            //  - We can add a single UIElement to that MapOverlay.Content
            MapLayer ml = new MapLayer();
            MapOverlay mo = new MapOverlay();

            // Add an Ellipse UI
            Ellipse r = new Ellipse();
            r.Fill = new SolidColorBrush(Color.FromArgb(255, 240, 5, 5));
            // the item is placed on the map at the top left corner so
            // in order to center it, we change the margin to a negative
            // margin equal to half the width and height
            r.Width = r.Height = 12;
            r.Margin = new Thickness(-6, -6, 0, 0);

            // Add the Ellipse to the Content 
            mo.Content = r;
            // Set the GeoCoordinate of that content
            mo.GeoCoordinate = geo;
            // Add the MapOverlay to the MapLayer
            ml.Add(mo);
            // Add the MapLayer to the Map
            controlMap.Layers.Add(ml);
        }
Пример #11
0
        void Seanslar_getCompleted(seanslar sender)
        {
            loader.IsIndeterminate = false;

            PanoramaRoot.Title = sender.SalonBilgisi.name;
            pItem1.DataContext = sender.SalonBilgisi;
            listFilmler.ItemsSource = sender.SalonBilgisi.movies;

            if (sender.SalonBilgisi.latitude.ToString() != "false")
            {
                SalonCoordinate = new GeoCoordinate(double.Parse(sender.SalonBilgisi.latitude), double.Parse(sender.SalonBilgisi.longitude));
                myMap.SetView(SalonCoordinate, 17);

                pinpoint_salon newPin = new pinpoint_salon();
                MapOverlay newOverlay = new MapOverlay();
                newOverlay.Content = newPin;
                newOverlay.GeoCoordinate = SalonCoordinate;
                newOverlay.PositionOrigin = new Point(0, 0);
                MapLayer MyLayer = new MapLayer();
                MyLayer.Add(newOverlay);
                myMap.Layers.Add(MyLayer);
            }
            else
            {
                myMap.Visibility = Visibility.Collapsed;
                recMap.Visibility = System.Windows.Visibility.Collapsed;
            }

        }
Пример #12
0
 /// <summary>
 /// Initializes values and points on map
 /// </summary>
 public async void init()
 {
     key = await Map.GetSessionIdAsync();
     _mapLayer = new MapLayer();
     _map = Map;
     _map.Children.Add(_mapLayer);
 }
Пример #13
0
        private void btnBrowseLayerPath_Click(object sender, EventArgs e)
        {
            OpenFileDialog oOpenFileDialog = new OpenFileDialog();

            oOpenFileDialog.Filter = "ShapeFile(*.shp) | *.shp";

            if (oOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.txtLayerPath.Text = oOpenFileDialog.FileName;

                BaseHandler.MapManager oMapManager = new GPSGatewaySimulator.BaseHandler.MapManager();
                this._layer = oMapManager.GetLayer(this.txtLayerPath.Text);

                if (this._layer == null)
                {
                    MessageBox.Show("����ָ���ĵ�ͼ�ļ�����ȷ.");
                    this.txtLayerPath.Clear();
                    return;
                }

                if (this._layer.shapeType != ShapeTypeConstants.moShapeTypeLine)
                {
                    MessageBox.Show("����ָ���ĵ�ͼ���������ͣ�������ѡ��.");
                    this.txtLayerPath.Clear();
                    return;
                }
            }
        }
Пример #14
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        public AgsCachedLayer(AgsServer server, MapLayer layer)
            : base(layer)
        {
            Debug.Assert(layer.MapServiceInfo != null);

            LayerType = AgsLayerType.Cached;
            Server = server;

            if (String.IsNullOrEmpty(layer.MapServiceInfo.Url))
                throw new SettingsException((string)App.Current.FindResource("InvalidMapLayerURL"));

            // format REST URL
            string restUrl = FormatRestUrl(layer.MapServiceInfo.Url);
            if (restUrl == null)
                throw new SettingsException((string)App.Current.FindResource("FailedFormatRESTURL"));

            // create ArcGIS layer
            ArcGISTiledMapServiceLayer arcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer();
            arcGISTiledMapServiceLayer.ID = "map";
            arcGISTiledMapServiceLayer.Url = restUrl;
            arcGISTiledMapServiceLayer.Visible = layer.MapServiceInfo.IsVisible;
            arcGISTiledMapServiceLayer.Opacity = layer.MapServiceInfo.Opacity;
            ArcGISLayer = arcGISTiledMapServiceLayer;

            UpdateTokenIfNeeded();
        }
Пример #15
0
 private void AddPinOnMap()
 {
     geo1 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].longitude));
     geo2 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].longitude));
     Image pinIMG = new Image();
     pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_green.png", UriKind.Relative));
     pinIMG.Width = 50;
     pinIMG.Height = 50;
     MapOverlay myLocationOverlay = new MapOverlay();
     myLocationOverlay.Content = pinIMG;
     myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
     myLocationOverlay.GeoCoordinate = geo1;
     MapLayer myLocationLayer = new MapLayer();
     myLocationLayer.Add(myLocationOverlay);
     mapJourney.Layers.Add(myLocationLayer);
     myLocationLayer = null;
     myLocationOverlay = null;
     pinIMG = null;
     pinIMG = new Image();
     pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_red.png", UriKind.Relative));
     pinIMG.Width = 50;
     pinIMG.Height = 50;
     myLocationOverlay = new MapOverlay();
     myLocationOverlay.Content = pinIMG;
     myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
     myLocationOverlay.GeoCoordinate = geo2;
     myLocationLayer = new MapLayer();
     myLocationLayer.Add(myLocationOverlay);
     mapJourney.Layers.Add(myLocationLayer);
     myLocationLayer = null;
     myLocationOverlay = null;
     pinIMG = null;
     mapJourney.ZoomLevel = ZoomLevel;
     mapJourney.Center = geo2;
 }
	void lockLayer(MapLayer mapLayer){
		GameObject child;
		for (int i = 0; i < mapLayer.gameObject.transform.childCount; i++){
			child = mapLayer.gameObject.transform.GetChild(i).gameObject;
			child.hideFlags = HideFlags.HideInHierarchy;
		}
	}
Пример #17
0
 public static void index2Coor(MapLayer layer, int index, out int x, out int y)
 {
     int row = index / layer.Width;//row is from 0 to 15
     int col = index % layer.Width;//col is from 0 to 15
     x=col;
     y=layer.Height-row-1;
 }
Пример #18
0
        void App_PositionUpdated(object sender, EventArgs e)
        {
            Dispatcher.BeginInvoke(() =>
            {
                ForeLocationCount++;

                if(oneMarker == null){
                    oneMarker = new MapOverlay();
                    MapLayer oneMarkerLayer = new MapLayer();

                    Ellipse Circhegraphic = new Ellipse();
                    Circhegraphic.Fill = new SolidColorBrush(Colors.Yellow);
                    Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
                    Circhegraphic.StrokeThickness = 10;
                    Circhegraphic.Opacity = 0.8;
                    Circhegraphic.Height = 30;
                    Circhegraphic.Width = 30;

                    oneMarker.Content = Circhegraphic;
                    oneMarker.PositionOrigin = new Point(0.5, 0.5);
       
                    oneMarkerLayer.Add(oneMarker);
                    map1.Layers.Add(oneMarkerLayer);
                }

                oneMarker.GeoCoordinate = App.lastLocation;

                if (!App.RunningInBackground)
                {
                    map1.Center = oneMarker.GeoCoordinate;
                }

                statusBox.Text = "Count :" + ForeLocationCount  + "/"+ App.GottenLocationsCunt + ", sess: " + App.RunningInBackgroundCunt;
            });   
        }
Пример #19
0
        public NewStore()
        {
            
            InitializeComponent();
            
            markerLayer = new MapLayer();
            map2.Layers.Add(markerLayer);

            //geoQ = new GeocodeQuery();
            //geoQ.QueryCompleted += geoQ_QueryCompleted;
            //Debug.WriteLine("All construction done for GeoCoding");

            System.Windows.Input.Touch.FrameReported += Touch_FrameReported;

            map2.Tap += map2_Tap;

            resultList.SelectionChanged += resultList_SelectionChanged;

            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
            watcher.MovementThreshold = 20; // 20 meters

            watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(OnStatusChanged);
            watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(OnPositionChanged);
            newCenter();
            watcher.Start();
        }
Пример #20
0
        private async void InitApartments()
        {
            var apartments = await App.MobileService.GetTable<Apartment>().Where(a => a.Published == true).ToListAsync();
            listApartments.ItemsSource = apartments;

            mapApartments.Layers.Clear();
            MapLayer layer = new MapLayer();
            foreach (Apartment apartment in apartments)
            {
                MapOverlay overlay = new MapOverlay();
                overlay.GeoCoordinate = new GeoCoordinate(apartment.Latitude, apartment.Longitude);
                overlay.PositionOrigin = new Point(0, 0);
                Grid grid = new Grid { Height = 40, Width = 25, Background = new SolidColorBrush(Colors.Red) };
                TextBlock text = new TextBlock { Text = apartment.Bedrooms.ToString(), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };
                grid.Children.Add(text);
                overlay.Content = grid;
                grid.Tap += (s, e) =>
                {
                    MessageBox.Show(
                        "Address: " + apartment.Address + Environment.NewLine + apartment.Bedrooms + " bedrooms",
                        "Apartment", MessageBoxButton.OK);
                    mapApartments.SetView(overlay.GeoCoordinate, 15, MapAnimationKind.Parabolic);
                };
                layer.Add(overlay);
            }
            mapApartments.Layers.Add(layer);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            string quakeQueryString = string.Empty;

            if (NavigationContext.QueryString.TryGetValue("quake", out quakeQueryString))
            {
                quake = Earthquake.DeserializeFromQueryString(quakeQueryString);
            }
            else return;

            ContentPanel.DataContext = quake;

            QuakeMap.Center = quake.Location;
            Pushpin pin = new Pushpin
            {
                GeoCoordinate = quake.Location,
                Content = quake.FormattedMagnitude
            };
            if (quake.Magnitude >= appSettings.MinimumWarningMagnitudeSetting)
                pin.Background = Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;

            MapOverlay overlay = new MapOverlay();
            overlay.Content = pin;
            overlay.GeoCoordinate = quake.Location;
            overlay.PositionOrigin = new Point(0, 1);

            MapLayer layer = new MapLayer();
            layer.Add(overlay);
            QuakeMap.Layers.Add(layer);

            base.OnNavigatedTo(e);
        }
Пример #22
0
        public SelectDestination()
        {
            InitializeComponent();
            street.Visibility = Visibility.Visible;
            (ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = true;
              
            GeoCoordinate geo = new GeoCoordinate();
            geo = MainPage.bookingData.current_location;
            googlemap.Center = geo;
            googlemap.ZoomLevel = 16;

            zzoom.IsEnabled = true;
            positionLoaded = true;

            Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
            new_pushpin.Location = geo;

            pushPinCurrentLocation = new MapLayer();

            new_pushpin.Content = "Current Location:\n ";
            new_pushpin.Content += MainPage.bookingData.current_location_address;
            new_pushpin.Visibility = Visibility.Visible;

            googlemap.Children.Add(pushPinCurrentLocation);
            pushPinCurrentLocation.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);

            
                if (MainPage.bookingData.isDesSet == true)
                {
                    AddressMapping();
                }

 
            
        }
Пример #23
0
        public MapView()
        {
            InitializeComponent();

            _layer = new MapLayer();
            _map.Children.Add(_layer);
        }
Пример #24
0
        private void AddMapIcon(Map map, GeoCoordinate geoPosition)
        {
            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();
            myCircle.Fill = new SolidColorBrush(Colors.Blue);
            myCircle.Height = 20;
            myCircle.Width = 20;
            myCircle.Opacity = 50;


            // Create a MapOverlay to contain the circle.
            MapOverlay myLocationOverlay = new MapOverlay();
            myLocationOverlay.Content = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate = geoPosition;


            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();
            myLocationLayer.Add(myLocationOverlay);

            // Add the MapLayer to the Map.
            maploc.Layers.Add(myLocationLayer);


        }
Пример #25
0
        //an initial create-map method
        public override void Generate(int seed, RDungeonFloor entry, List<FloorBorder> floorBorders, Dictionary<int, List<int>> borderLinks)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed = seed;
            this.entry = entry;
            FloorBorders = floorBorders;
            BorderLinks = borderLinks;

            BorderPoints = new Loc2D[1];

            rand = new Random(seed);

            MapArray = new Tile[10, 10];

            MapLayer ground = new MapLayer(Width, Height);
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                    GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                }
            }

            BorderPoints[0] = new Loc2D(0, 0);
        }
Пример #26
0
        void GenerarMap()
        {
            //double lat = 13.3039361;
            //double longi = -87.1818977;

            //double myLat = 13.309102541101671;
            //double myLongi = -87.18679750841795;

            myCoordinates.Add(new System.Device.Location.GeoCoordinate(lat, longi));
            myCoordinates.Add(new System.Device.Location.GeoCoordinate(myLat, myLongi));

            

            //myGeocode = new GeocodeQuery();
            //myGeocode.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);
            //myGeocode.QueryCompleted += myGeocode_QueryCompleted;
            //myGeocode.QueryAsync();

            myQuery = new RouteQuery();
            myQuery.Waypoints = myCoordinates;
            myQuery.QueryCompleted += myQuery_QueryCompleted;
            myQuery.QueryAsync();
            mapPlace.Center = new System.Device.Location.GeoCoordinate(myLat, myLongi);

           
            MapLayer myLayer = new MapLayer();

            Pushpin myPushpin = new Pushpin();
            MapOverlay myOverlay = new MapOverlay();
            myPushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);

            myPushpin.Content = "I'm Here";

            myOverlay.Content = myPushpin;
            myOverlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);
            myLayer.Add(myOverlay);

            Pushpin pushpin = new Pushpin();
            MapOverlay overlay = new MapOverlay();
            pushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi);

            pushpin.Content = PlaceName;

            overlay.Content = pushpin;
            overlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi);
            myLayer.Add(overlay);

            mapPlace.Layers.Add(myLayer);

            //Animacion del mapa
            mapPlace.SetView(new System.Device.Location.GeoCoordinate()
            {
                Latitude = lat,
                Longitude = longi
            }, 16, Microsoft.Phone.Maps.Controls.MapAnimationKind.Parabolic);


            
        }
	void unlockLayer(MapLayer mapLayer){
		GameObject child;
		for (int i = 0; i < mapLayer.gameObject.transform.childCount; i++){
			child = mapLayer.gameObject.transform.GetChild(i).gameObject;
			child.hideFlags = 0;
			child.transform.hideFlags = HideFlags.HideInHierarchy; //Provisorio para teste
		}
	}
Пример #28
0
 public override void OnFocus()
 {
     map = mapState.Map;
     currentLayer = map.Layers[(int)mapState.CurrentLayer];
     float scalex = (float)Moxy.ScreenWidth / (float)currentLayer.LayerTexture.Width;
     float scaley = (float)Moxy.ScreenHeight / (float)currentLayer.LayerTexture.Height;
     scale = Math.Min(scalex, scaley);
 }
Пример #29
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        protected AgsLayer(MapLayer layer)
        {
            _id = layer.Id;

            // attach to events
            layer.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(layer_PropertyChanged);
            MapLayer = layer;
        }
Пример #30
0
        private async void AddressMapping()
        {
            googlemap.Children.Remove(pushPinLayer);
            pushPinLayer = new MapLayer();

            try
            {
                GeoCoordinate geo = new GeoCoordinate(MainPage.bookingData.lat, MainPage.bookingData.lng);

                Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
                new_pushpin.Location = geo;
                googlemap.Center = geo;

                string url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + geo.Latitude + "," + geo.Longitude + "&sensor=true";
                var client = new WebClient();

                string response = await client.DownloadStringTaskAsync(new Uri(url));
                JObject root = JObject.Parse(response);

                JArray items = (JArray)root["results"];
                JObject item;
                JToken jtoken;
                item = (JObject)items[0];
                JArray add_comp = (JArray)item["address_components"];
                string address = null;
                string[] add_types = { "street_number", "route", "neighborhood", "locality", "city", "country" };
                foreach (var comp in add_comp)
                {
                    if (add_types.Any(comp["types"].ToString().Contains))
                    {
                        address += comp["long_name"].ToString() + ", ";
                        if (comp["types"].ToString().Contains("city") | comp["types"].ToString().Contains("country"))
                        {
                            address += "\n";
                        }
                    }
                }

                (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = true;
                (ApplicationBar.Buttons[2] as ApplicationBarIconButton).IsEnabled = true;

                new_pushpin.Content = "Destination Location:\n" + address;

                Address.Text = address;
                new_pushpin.Visibility = Visibility.Visible;

                googlemap.Children.Add(pushPinLayer);
                pushPinLayer.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);
                MainPage.bookingData.set_destination_attributes(address, geo);
                LatitudeTextBlock.Text = "Latitude:  " + geo.Latitude.ToString("0.00"); //geoposition.Coordinate.Latitude.ToString("0.00"); //
                LongitudeTextBlock.Text = "Longitude: " + geo.Longitude.ToString("0.00");//geoposition.Coordinate.Longitude.ToString("0.00"); //
            }
            catch (Exception ed)
            {
                MessageBox.Show(ed.ToString());
            }
        }
Пример #31
0
        private void Pushpins()
        {
            Ellipse eli = new Ellipse();

            eli.Width  = 20;
            eli.Height = 20;
            eli.Fill   = new SolidColorBrush(Colors.Blue);

            MapOverlay mapOverlay = new MapOverlay();

            mapOverlay.Content       = eli;
            mapOverlay.GeoCoordinate = new GeoCoordinate(myGeoPosition.Coordinate.Latitude, myGeoPosition.Coordinate.Longitude);

            MapLayer mapLayer = new MapLayer();

            mapLayer.Add(mapOverlay);

            MyMap.Layers.Add(mapLayer);

            //OtherPushpins();
        }
Пример #32
0
        private void addImageToMap(object sender, RoutedEventArgs e)
        {
            MapLayer imageLayer = new MapLayer();


            Image image = new Image();

            image.Height = 150;
            //Define the URI location of the image
            BitmapImage myBitmapImage = new BitmapImage();

            myBitmapImage.BeginInit();
            myBitmapImage.UriSource = new Uri("http://upload.wikimedia.org/wikipedia/commons/d/d4/Golden_Gate_Bridge10.JPG");
            // To save significant application memory, set the DecodePixelWidth or
            // DecodePixelHeight of the BitmapImage value of the image source to the desired
            // height or width of the rendered image. If you don't do this, the application will
            // cache the image as though it were rendered as its normal size rather then just
            // the size that is displayed.
            // Note: In order to preserve aspect ratio, set DecodePixelWidth
            // or DecodePixelHeight but not both.
            //Define the image display properties
            myBitmapImage.DecodePixelHeight = 150;
            myBitmapImage.EndInit();
            image.Source  = myBitmapImage;
            image.Opacity = 0.6;
            image.Stretch = System.Windows.Media.Stretch.None;

            //The map location to place the image at
            Location location = new Location()
            {
                Latitude = 37.8197222222222, Longitude = -122.478611111111
            };
            //Center the image around the location specified
            PositionOrigin position = PositionOrigin.Center;

            //Add the image to the defined map layer
            imageLayer.AddChild(image, location, position);
            //Add the image layer to the map
            MapTileOverlay.Children.Add(imageLayer);
        }
Пример #33
0
        public async Task <MapLayer> CreateMapLayerAsync(NaheulbookExecutionContext executionContext, int mapId, MapLayerRequest request)
        {
            using (var uow = _unitOfWorkFactory.CreateUnitOfWork())
            {
                switch (request.Source)
                {
                case "official":
                    await _authorizationUtil.EnsureAdminAccessAsync(executionContext);

                    break;

                case "private":
                    break;

                default:
                    throw new InvalidSourceException(request.Source);
                }

                var map = await uow.Maps.GetAsync(mapId);

                if (map == null)
                {
                    throw new MapNotFoundException(mapId);
                }

                var mapLayer = new MapLayer
                {
                    Name   = request.Name,
                    Source = request.Source,
                    IsGm   = request.IsGm,
                    MapId  = mapId,
                    UserId = request.Source == "official" ? (int?)null : executionContext.UserId
                };

                uow.MapLayers.Add(mapLayer);
                await uow.SaveChangesAsync();

                return(mapLayer);
            }
        }
Пример #34
0
        private async void ShowMyLocationOnTheMap()
        {
            // Get my current location.
            Geolocator  myGeolocator  = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();

            Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
            GeoCoordinate myGeoCoordinate = ShowMyLocationOnMap.CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);


            this.maploc.Center    = myGeoCoordinate;
            this.maploc.ZoomLevel = 13.8;



            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();

            myCircle.Fill    = new SolidColorBrush(System.Windows.Media.Colors.Red);
            myCircle.Height  = 20;
            myCircle.Width   = 20;
            myCircle.Opacity = 50;


            // Create a MapOverlay to contain the circle.
            MapOverlay myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = myGeoCoordinate;


            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();

            myLocationLayer.Add(myLocationOverlay);

            // Add the MapLayer to the Map.
            maploc.Layers.Add(myLocationLayer);
        }
Пример #35
0
        /// <summary>
        /// Open a layer
        /// </summary>
        /// <param name="aFile">layer file path</param>
        /// <returns>map layer</returns>
        public static MapLayer OpenLayer(string aFile)
        {
            MapLayer aLayer = null;

            if (File.Exists(aFile))
            {
                switch (Path.GetExtension(aFile).ToLower())
                {
                case ".dat":
                    aLayer = MapDataManage.ReadMapFile_MICAPS(aFile);
                    break;

                case ".shp":
                    aLayer = MapDataManage.ReadMapFile_ShapeFile(aFile);
                    break;

                case ".wmp":
                    aLayer = MapDataManage.ReadMapFile_WMP(aFile);
                    break;

                case ".bln":
                    aLayer = MapDataManage.ReadMapFile_BLN(aFile);
                    break;

                case ".bmp":
                case ".gif":
                case ".jpg":
                case ".tif":
                case ".png":
                    aLayer = MapDataManage.ReadImageFile(aFile);
                    break;

                default:
                    aLayer = MapDataManage.ReadMapFile_GrADS(aFile);
                    break;
                }
            }

            return(aLayer);
        }
Пример #36
0
        private void UpdatePins()
        {
            var map     = Control;
            var mapTile = (MapTile)Element;

            var toRemove = new List <MapLayer>();

            foreach (var item in map.Layers)
            {
                if (item.Count > 0)
                {
                    if (item[0].Content is PinMarker)
                    {
                        toRemove.Add(item);
                    }
                }
            }

            foreach (var item in toRemove)
            {
                map.Layers.Remove(item);
            }

            foreach (var item in mapTile.PinList)
            {
                var pinMarker = new PinMarker(item);
                pinMarker.Tap += pinMarker_Tap;

                MapOverlay overlayPin = new MapOverlay
                {
                    GeoCoordinate  = new System.Device.Location.GeoCoordinate(item.Latitude, item.Longitude),
                    PositionOrigin = new System.Windows.Point(0.5, 1.0),
                    Content        = pinMarker,
                };

                MapLayer layerPin = new MapLayer();
                layerPin.Add(overlayPin);
                map.Layers.Add(layerPin);
            }
        }
Пример #37
0
        private void UpdateData(Geoposition geoposition)
        {
            _longitude = (double)geoposition.Coordinate.Longitude;
            _latitude  = (double)geoposition.Coordinate.Latitude;
            _altitude  = (double)geoposition.Coordinate.Altitude;

            this.textBlockLongitude.Text = "Longitude: " + _longitude.ToString();
            this.textBlockLatitude.Text  = "Latitude: " + _latitude.ToString();
            this.textBlockAltitude.Text  = "Altitude: " + _altitude.ToString();

            this.map.Center                    = new GeoCoordinate(_latitude, _longitude);
            this.map.ZoomLevel                 = 13;
            this.map.LandmarksEnabled          = true;
            this.map.PedestrianFeaturesEnabled = true;

            //_mapIconPosition.Location = geoposition.Coordinate.Point;

            System.Windows.Shapes.Ellipse myCircle = new Ellipse();
            myCircle.Fill    = new System.Windows.Media.SolidColorBrush(Colors.Blue);
            myCircle.Height  = 15;
            myCircle.Width   = 15;
            myCircle.Opacity = 25;

            MapOverlay myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = new GeoCoordinate(_latitude, _longitude);

            MapLayer myLocationLayer = new MapLayer();

            myLocationLayer.Add(myLocationOverlay);

            this.map.Layers.Add(myLocationLayer);

            if (this._isTrackingStarted == true)
            {
                WritePositionToFile();
            }
        }
        void Utility_QueryComplete(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            try
            {
                if (!String.IsNullOrEmpty(NameTextBox.Text) && e.Result.Count == 0)
                {
                    MessageBox.Show(string.Format(AppResources.InvalideSearch, NameTextBox.Text), AppResources.Warning, MessageBoxButton.OK);
                    return;
                }

                GeoCoordinate coord = new GeoCoordinate();
                foreach (var item in e.Result)
                {
                    coord            = item.GeoCoordinate;
                    NameTextBox.Text = Utils.Utility.getCompleteAddress(item.Information.Address);
                }

                MapLayer   pinLayout  = new MapLayer();
                Pushpin    MyPushpin  = new Pushpin();
                MapOverlay pinOverlay = new MapOverlay();
                if (myMap.Layers.Count > 0)
                {
                    myMap.Layers.RemoveAt(myMap.Layers.Count - 1);
                }

                myMap.Layers.Add(pinLayout);

                MyPushpin.GeoCoordinate = coord;

                pinOverlay.Content        = MyPushpin;
                pinOverlay.GeoCoordinate  = MyPushpin.GeoCoordinate;
                pinOverlay.PositionOrigin = new Point(0, 1);
                pinLayout.Add(pinOverlay);
                MyPushpin.Content = AppResources.MyTour;

                ViewModel.Tour.Latitude  = coord.Latitude;
                ViewModel.Tour.Longitude = coord.Longitude;
            }
            catch (Exception ex) { throw ex; }
        }
Пример #39
0
        private void SearchPaneQuerySubmitted(
            SearchPane sender,
            SearchPaneQuerySubmittedEventArgs args)
        {
            GeocodeLocation geoCodeLocation = _searchResponse.LocationData
                                              .FirstOrDefault(locationData => locationData.Address.FormattedAddress == args.QueryText) ??
                                              _searchResponse.LocationData.FirstOrDefault();

            _lastFocusedMapPin = _focusedMapPin;

            if (geoCodeLocation != null)
            {
                MapPin existedMapPin = _mapPins.FirstOrDefault(mapPin =>
                                                               mapPin.Latitude == geoCodeLocation.Location.Latitude.ToString() &&
                                                               mapPin.Longitude == geoCodeLocation.Location.Longitude.ToString());
                if (existedMapPin == null)
                {
                    MapPin mapPinElement = new MapPin(string.Empty, string.Empty,
                                                      geoCodeLocation.Location.Latitude.ToString(),
                                                      geoCodeLocation.Location.Longitude.ToString());

                    mapPinElement.MapPinTapped += MapPinElementMapPinTapped;
                    MapView.Children.Add(mapPinElement);
                    MapLayer.SetPosition(mapPinElement, geoCodeLocation.Location);
                    MapView.SetView(geoCodeLocation.Location, 15.0f);
                    _focusedMapPin = mapPinElement;
                }
                else
                {
                    Location location = new Location(double.Parse(existedMapPin.Latitude), double.Parse(existedMapPin.Longitude));
                    MapView.SetView(location, 15.0f);
                    existedMapPin.Focus();
                    _focusedMapPin = existedMapPin;
                }
                DefaultViewModel["Focused"] = true;
            }
            DefaultViewModel["Linkable"]   = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked;
            DefaultViewModel["Markable"]   = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"];
            DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"];
        }
Пример #40
0
        private void geoQ_DestinoQueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            var list = e.Result.Where(x => x.Information.Address.Neighborhood.Equals("Gran Buenos Aires")).ToList();

            LoadingDestino.Visibility  = Visibility.Collapsed;
            BtnBuscarDestino.IsEnabled = true;

            if (list.Any())
            {
                var mapLayer = new MapLayer();

                for (int index = 1; index <= list.Count; index++)
                {
                    var mapLocation = list[index - 1];
                    var nombre      = string.Format("{0}. {1} {2}", index, mapLocation.Information.Address.Street, mapLocation.Information.Address.HouseNumber);
                    var detalles    = mapLocation.Information.Address.District;
                    if (!string.IsNullOrWhiteSpace(detalles))
                    {
                        detalles += ", ";
                    }
                    detalles += mapLocation.Information.Address.City;

                    ViewModel.BusquedaDestino.Add(new GeocoderResult
                    {
                        Nombre   = nombre,
                        Detalles = detalles,
                        X        = mapLocation.GeoCoordinate.Latitude,
                        Y        = mapLocation.GeoCoordinate.Longitude,
                    });
                    mapLayer.Add(GetMapOverlay(index.ToString(CultureInfo.InvariantCulture), mapLocation.GeoCoordinate));
                }

                MiMapaDestino.Layers.Add(mapLayer);
                SetMapView(MiMapaDestino, mapLayer);
            }
            else
            {
                NoResultsDestino.Visibility = Visibility.Visible;
            }
        }
Пример #41
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Geolocator geolocator = new Geolocator();

            geolocator.DesiredAccuracy = PositionAccuracy.High;

            try
            {
                //  Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10));
                //  _accuracy = currentPosition.Coordinate.Accuracy;

                Dispatcher.BeginInvoke(() =>
                {
                    MyCoordinate = new GeoCoordinate(36.115381, -115.198145); //hard coded the location of Palms casino in Vegas (venue)
                    MyMap.Layers.Clear();

                    //On one layer draw store locations
                    MapLayer layer = new MapLayer();
                    foreach (PointOfInterest p in locations)
                    {
                        DrawMapMarker(p.coord, Colors.Red, layer);
                    }

                    MyMap.Layers.Add(layer);

                    //On next layer draw my location
                    MapLayer currLocLayer = new MapLayer();
                    DrawMapMarker(MyCoordinate, Colors.Blue, currLocLayer);
                    MyMap.Layers.Add(currLocLayer);

                    //Animate into view
                    MyMap.SetView(MyCoordinate, 13, MapAnimationKind.Linear);
                });
            }
            catch (Exception)
            {
                Debug.WriteLine("Problem setting current position in Map");
            }
        }
        //public MapTileVectorDataSource(string url)
        //{
        //    Uri = url;
        //    _geoStream = new FileStream(url, FileMode.Open);
        //    byte[] bufferGeo = new byte[_geoStream.Length];
        //    _geoStream.Read(bufferGeo, 0, bufferGeo.Length);
        //    _geoStream.Close();
        //    MemoryStream baisGeo = new MemoryStream(bufferGeo);
        //    _getSet = new GeoSet(new BinaryReader(baisGeo));
        //    string filePath = Path.GetDirectoryName(url);
        //    string[] layerNames = _getSet.GetLayerNames();
        //    _layerStreams = new FileStream[layerNames.Length];
        //    for (int i = 0; i < layerNames.Length; i++)
        //    {
        //        string layerName = filePath + "\\" + layerNames[i];
        //        _layerStreams[i] = new FileStream(layerName, FileMode.Open);
        //        MapFeatureLayer layer = new MapFeatureLayer(new BinaryReader(_layerStreams[i]));
        //        layer.FontColor = 0x000000;
        //        GeoSet.MapFeatureLayerInfo layerInfo = _getSet.GetMapMapFeatureLayerInfo(layerNames[i]);
        //        if (layerInfo != null)
        //        {
        //            layer.ZoomLevel = layerInfo.ZoomLevel;
        //            layer.ZoomMin = layerInfo.ZoomMin;
        //            layer.ZoomMax = layerInfo.ZoomMax;
        //            layer.Description = layerInfo.Description;
        //            layer.Visible = layerInfo.Visible;
        //            layer.LayerName = layerInfo.LayerName;
        //        }
        //        _getSet.AddMapFeatureLayer(layer);
        //    }

        //    _vectorMapRenderer = new VectorMapRenderer(_getSet);
        //    Font font = new Font(FontFamily.GenericSansSerif, 13, FontStyle.Regular);
        //    IFont newFont = MapLayer.GetAbstractGraphicsFactory().CreateFont(font);
        //    _vectorMapRenderer.SetFont(newFont);
        //    _getSet.Open();

        //}


        public MapTileVectorDataSource(string url)
        {
            Uri        = url;
            _geoStream = new FileStream(url, FileMode.Open);
            byte[] bufferGeo = new byte[_geoStream.Length];
            _geoStream.Read(bufferGeo, 0, bufferGeo.Length);
            _geoStream.Close();
            MemoryStream baisGeo = new MemoryStream(bufferGeo);

            _getSet = new GeoSet();
            string filePath = @"C:\shenjing\map";

            string[] layerNames = new string[] { "3.lyr", "1.lyr", "2.lyr" };
            _layerStreams = new FileStream[layerNames.Length];
            for (int i = 0; i < layerNames.Length; i++)
            {
                string layerName = filePath + "\\" + layerNames[i];
                _layerStreams[i] = new FileStream(layerName, FileMode.Open);
                MapFeatureLayer layer = new MapFeatureLayer(new BinaryReader(_layerStreams[i]));
                layer.FontColor = 0x000000;
                GeoSet.MapFeatureLayerInfo layerInfo = _getSet.GetMapMapFeatureLayerInfo(layerNames[i]);
                if (layerInfo != null)
                {
                    layer.ZoomLevel   = layerInfo.ZoomLevel;
                    layer.ZoomMin     = layerInfo.ZoomMin;
                    layer.ZoomMax     = layerInfo.ZoomMax;
                    layer.Description = layerInfo.Description;
                    layer.Visible     = layerInfo.Visible;
                    layer.LayerName   = layerInfo.LayerName;
                }
                _getSet.AddMapFeatureLayer(layer);
            }

            _vectorMapRenderer = new VectorMapRenderer(_getSet);
            Font  font    = new Font(FontFamily.GenericSansSerif, 13, FontStyle.Regular);
            IFont newFont = MapLayer.GetAbstractGraphicsFactory().CreateFont(font);

            _vectorMapRenderer.SetFont(newFont);
            _getSet.Open();
        }
        private void GetMyLocation()
        {
            string _urlResponse       = "";
            string _ipinfodb_apikey   = "_ipinfodb_apikey";
            string _mypublicipaddress = GetPublicIpAddress();
            string _urlRequest        = "http://api.ipinfodb.com/v3/ip-city/?key=" + _ipinfodb_apikey + "&" + _mypublicipaddress;

            var request = (HttpWebRequest)WebRequest.Create(_urlRequest);

            request.UserAgent = "curl";

            request.Method = "GET";
            using (WebResponse response = request.GetResponse())
            {
                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    _urlResponse = reader.ReadToEnd();
                }
            }

            string[] _myGeocodeInfo = _urlResponse.Split(';');

            Location myLoc = new Location(Convert.ToDouble(_myGeocodeInfo[8]), Convert.ToDouble(_myGeocodeInfo[9]));

            myMap.SetView(myLoc, Convert.ToDouble(14), Convert.ToDouble(0));

            Pushpin myPin = new Pushpin();

            MapLayer.SetPosition(myPin, myLoc);
            myMap.Children.Add(myPin);

            System.Windows.Controls.Label label = new System.Windows.Controls.Label();
            label.Content    = "Here I AM!";
            label.Foreground = new SolidColorBrush(Colors.DarkBlue);
            label.Background = new SolidColorBrush(Colors.WhiteSmoke);
            label.FontSize   = 30;
            MapLayer.SetPosition(label, myLoc);
            myMap.Children.Add(label);
        }
Пример #44
0
        private async void Map_Loaded(object sender, RoutedEventArgs e)
        {
            var    bounds = Window.Current.Bounds;
            double height = bounds.Height;
            double width  = bounds.Width;

            ((Map)sender).Height = height;

            var map = ((Map)sender);

            try
            {
                _geolocator = new Geolocator();
                Geoposition pos = await _geolocator.GetGeopositionAsync();

                Location mylocation = new Location(pos.Coordinate.Point.Position.Latitude,
                                                   pos.Coordinate.Point.Position.Longitude);
                var zoomLevel = 10;
                map.SetView(mylocation, zoomLevel);
            }
            catch { }

            var rmain = ServiceLocator.Current.GetInstance <MainViewModel>();

            foreach (ChildPlaceItem item in rmain.ChildPlaceItems)
            {
                try
                {
                    Pushpin pushpin  = new Pushpin();
                    var     location = new Location(Double.Parse(item.Y), Double.Parse(item.X));
                    MapLayer.SetPosition(pushpin, location);
                    pushpin.Name    = item.Id.ToString();
                    pushpin.Tapped += pushpinTapped;
                    map.Children.Add(pushpin);
                }
                catch { }
            }
            ;
        }
Пример #45
0
        void MyPositionChanged(GeoPositionChangedEventArgs <GeoCoordinate> e)
        {
            // Update the map to show the current location
            Location ppLoc = new Location();

            ppLoc.Latitude  = e.Position.Location.Latitude;
            ppLoc.Longitude = e.Position.Location.Longitude;
            mapMain.SetView(ppLoc, 15.0);

            //update pushpin location and show
            MapLayer.SetPosition(ppLocation, ppLoc);
            ppLocation.Visibility = System.Windows.Visibility.Visible;
            if (e.Position.Location.Altitude.Equals(0.0))
            {
                tbStatus.Text   = "finding altitude...";
                tbAltitude.Text = "?m. (?ft.)";
            }
            else
            {
                tbAltitude.Text = string.Format("{0:0.00} ", e.Position.Location.Altitude) + "m. (" + string.Format("{0:0.00} ", e.Position.Location.Altitude * 3.2808399) + " ft.)";
            }
        }
Пример #46
0
        private async void UpdatePosition()
        {
            try {
                var assignment = assignmentViewModel.SelectedAssignment;
                var position   = await locator.GetGeopositionAsync();

                var location = new Location(position.Coordinate.Latitude, position.Coordinate.Longitude);

                //Set the user's pin
                const double spacing = 3;
                MapLayer.SetPosition(userPin, location);
                var northWest = new Location(Math.Max(assignment.Latitude, location.Latitude), Math.Min(assignment.Longitude, location.Longitude));
                northWest.Longitude -= spacing;
                northWest.Latitude  += spacing;
                var southEast = new Location(Math.Min(assignment.Latitude, location.Latitude), Math.Max(assignment.Longitude, location.Longitude));
                southEast.Longitude += spacing;
                southEast.Latitude  -= spacing;
                map.SetView(new LocationRect(northWest, southEast));
            } catch (Exception exc) {
                System.Diagnostics.Debug.WriteLine("Error updating position: " + exc.Message);
            }
        }
Пример #47
0
        private void BikePointPin_PointerEntered(object sender, PointerRoutedEventArgs e)
        {
            var up = new PlaneProjection {
                LocalOffsetY = 80
            };

            _mapInfoCanvas.Projection = up;

            _mapInfoCanvas.Opacity = 0.7;
            _tapped = false;
            var pin = sender as Pushpin;

            pin.Background = new SolidColorBrush(Colors.Tomato);
            var pos = MapLayer.GetPosition(pin);

            foreach (var item in BikeDataGroups
                     .Where(item => item.Lat == pos.Latitude)
                     .Where(item => item.Lon == pos.Longitude))
            {
                _mainName.Text = item.CommonName;
            }
        }
Пример #48
0
        private void HandleCheckins(List <CheckInLocation> arg1, BuddyCallbackParams arg2)
        {
            // marker = new MapLayer();
            MapLayer layer = new MapLayer();

            foreach (CheckInLocation x in arg1)
            {
                MapOverlay overlay = new MapOverlay
                {
                    GeoCoordinate = new GeoCoordinate(x.Latitude, x.Longitude),
                    Content       = new Ellipse
                    {
                        Fill   = new SolidColorBrush(Colors.Red),
                        Width  = 10,
                        Height = 10
                    }
                };

                layer.Add(overlay);
            }
            map.Layers.Add(layer);
        }
Пример #49
0
        /// <summary>A simple animation that drops a pin from a height above it's destinated location onto the map.</summary>
        /// <param name="pin">The pushpin to perform the animation on.</param>
        /// <param name="height">The height above the destinated location to drop the pushpin from. Default is 150 pixels.</param>
        /// <param name="duration">Length of time in ms that the animation should run for. Default is 150 ms.</param>
        public static void Drop(UIElement pin, double?height, int?duration)
        {
            height   = (height.HasValue && height.Value > 0) ? height : 150;
            duration = (duration.HasValue && duration.Value > 0) ? duration : 150;

#if WINDOWS_APP
            var anchor = MapLayer.GetPositionAnchor(pin);
#elif WPF
            var anchor = MapLayer.GetPositionOffset(pin);
#elif WINDOWS_PHONE
            var anchor = new System.Windows.Point(0, 0);
#elif WINDOWS_PHONE_APP
            var anchor = MapControl.GetNormalizedAnchorPoint(pin);
#endif

            var from = anchor.Y + height.Value;

            AnimateY(pin, -from, -anchor.Y, duration.Value, new QuadraticEase()
            {
                EasingMode = EasingMode.EaseIn
            });
        }
Пример #50
0
        void newLayerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (FormNewLayer frmNewLayer = new FormNewLayer(mData.MapWidth, mData.MapHeight))
            {
                frmNewLayer.ShowDialog();

                if (frmNewLayer.OKPressed)
                {
                    MapLayerData data = frmNewLayer.MapLayerData;

                    if (clbLayers.Items.Contains(data.MapLayerName))
                    {
                        MessageBox.Show("Layer with name " + data.MapLayerName + " exists.", "Existing layer");
                        return;
                    }

                    MapLayer layer = MapLayer.FromMapLayerData(data);
                    clbLayers.Items.Add(data.MapLayerName, true);
                    clbLayers.SelectedIndex = clbLayers.Items.Count - 1;

                    layers.Add(layer);

                    if (map == null)
                    {
                        map = new TileMapIso(tileSets[0], (MapLayer)layers[0]);

                        for (int i = 1; i < tileSets.Count; i++)
                        {
                            map.AddTileset(tileSets[1]);
                        }

                        for (int i = 1; i < layers.Count; i++)
                        {
                            map.AddLayer(layers[1]);
                        }
                    }
                }
            }
        }
 private void LayoutMap_MapViewUpdated(object sender, EventArgs e)
 {
     if (_graphic.Legend.GetType() == typeof(VectorBreak))
     {
         for (int i = 0; i < _layoutMap.MapFrame.MapView.LayerSet.Layers.Count; i++)
         {
             MapLayer aLayer = _layoutMap.MapFrame.MapView.LayerSet.Layers[_layoutMap.MapFrame.MapView.LayerSet.Layers.Count - 1 - i];
             if (aLayer.LayerType == LayerTypes.VectorLayer)
             {
                 if (aLayer.Visible && aLayer.LayerDrawType == LayerDrawType.Vector)
                 {
                     this.Visible = true;
                     float zoom = ((VectorLayer)aLayer).DrawingZoom;
                     ((VectorBreak)_graphic.Legend).Zoom = zoom;
                     float     max  = 30.0f / zoom;
                     WindArraw aWA  = (WindArraw)_graphic.Shape;
                     int       llen = 5;
                     for (i = 10; i <= 100; i += 5)
                     {
                         if (max < i)
                         {
                             llen = i - 5;
                             break;
                         }
                     }
                     aWA.length = llen;
                     aWA.size   = 5;
                     aWA.Value  = 0;
                     UpdateControlSize();
                     //if (_defaultLegend.Visible)
                     //    _defaultWindArraw.Top = _defaultLegend.Bottom + 10;
                     //else
                     //    _defaultWindArraw.Top = _defaultLayoutMap.Bottom;
                     break;
                 }
             }
         }
     }
 }
Пример #52
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Construtor.
         */
        public VectorMapCanvas()
        {
            GetGraphics2DInstance();
            _textImage = MapLayer.GetAbstractGraphicsFactory()
                         .CreateImage(MapLayer.MAP_TILE_WIDTH,
                                      IMAGE_PATERN_WIDTH);
            _textGraphics = _textImage.GetGraphics();
            _textGraphics.SetColor(0xC0C0FF);
            _textGraphics.FillRect(0, 0, _textImage.GetWidth(), _textImage.GetHeight());
            _fontTranspency = _textImage.GetRGB()[0];
            _imagePattern   = MapLayer.GetAbstractGraphicsFactory()
                              .CreateImage(IMAGE_PATERN_WIDTH,
                                           IMAGE_PATERN_WIDTH);

            _imagePatternGraphics = _imagePattern.GetGraphics();

            _mapSize.X      = 0; _mapSize.Y = 0;
            _mapSize.MaxX   = MapLayer.MAP_TILE_WIDTH;
            _mapSize.MaxY   = MapLayer.MAP_TILE_WIDTH;
            _mapSize.Width  = MapLayer.MAP_TILE_WIDTH;
            _mapSize.Height = MapLayer.MAP_TILE_WIDTH;
        }
Пример #53
0
        public void showStores()
        {
            MapLayer mapLayer = new MapLayer();

            map1.Layers.Add(mapLayer);

            System.Windows.Media.Color color = System.Windows.Media.Colors.Red;



            foreach (var store in App.storeViewModel.Stores)
            {
                double lat = store.Lat;
                double lon = store.Lon;
                System.Diagnostics.Debug.WriteLine("adding store" + lat + " " + lon + "/n");
                GeoCoordinate coordinate = new GeoCoordinate();
                coordinate.Latitude  = lat;
                coordinate.Longitude = lon;

                DrawMapMarker(coordinate, color, mapLayer);
            }
        }
Пример #54
0
        private void Map_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            //Check if the user is currently dragging the Pushpin
            if (this.isDragging)
            {
                //If so, move the Pushpin to where the pointer is.
                var pointerPosition = e.GetCurrentPoint(_map);

                Bing.Maps.Location location = null;

                //Convert the point pixel to a Location coordinate
                if (_map.TryPixelToLocation(pointerPosition.Position, out location))
                {
                    MapLayer.SetPosition(this, location);
                }

                if (Drag != null)
                {
                    Drag(location);
                }
            }
        }
Пример #55
0
        // ::Draw map point
        private void _DrawPoint(double latitude, double longitude)
        {
            Ellipse myCircle = new Ellipse();

            myCircle.Fill    = new SolidColorBrush(Colors.Blue);
            myCircle.Height  = 20;
            myCircle.Width   = 20;
            myCircle.Opacity = 50;

            MapOverlay myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = new GeoCoordinate(latitude, longitude);

            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();

            myLocationLayer.Add(myLocationOverlay);

            MapOfRunningRoute.Layers.Add(myLocationLayer);
        }
Пример #56
0
        private void btn_Map_Click(object sender, RoutedEventArgs e)
        {
            sp_Map.Visibility     = Visibility.Visible;
            sp_Content.Visibility = Visibility.Collapsed;
            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
            watcher.Start();

            map.SetView(watcher.Position.Location, 14);
            map.Mode = new AerialMode();
            Pin_My   = new Image();
            Pin_My   = new Image()
            {
                Source = new BitmapImage(new Uri("/Image_Acquirer/man.png", UriKind.Relative))
            };
            Pin_My.Width  = 40;
            Pin_My.Height = 50;
            layer         = new MapLayer();
            map.Children.Add(layer);
            layer.AddChild(Pin_My, watcher.Position.Location);
            Pin_My.Tag = watcher.Position.Location;
            map.Tap   += new EventHandler <System.Windows.Input.GestureEventArgs>(map_Tap);
        }
Пример #57
0
        public void AddPushpin(BasicGeoposition location, string text)
        {
#if WINDOWS_APP
            var pin = new Pushpin()
            {
                Text = text
            };
            MapLayer.SetPosition(pin, location.ToLocation());
            _pinLayer.Children.Add(pin);
#elif WINDOWS_PHONE_APP
            var pin = new Grid()
            {
                Width  = 24,
                Height = 24,
                Margin = new Windows.UI.Xaml.Thickness(-12)
            };

            pin.Children.Add(new Ellipse()
            {
                Fill            = new SolidColorBrush(Colors.DodgerBlue),
                Stroke          = new SolidColorBrush(Colors.White),
                StrokeThickness = 3,
                Width           = 24,
                Height          = 24
            });

            pin.Children.Add(new TextBlock()
            {
                Text                = text,
                FontSize            = 12,
                Foreground          = new SolidColorBrush(Colors.White),
                HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
                VerticalAlignment   = Windows.UI.Xaml.VerticalAlignment.Center
            });

            MapControl.SetLocation(pin, new Geopoint(location));
            _map.Children.Add(pin);
#endif
        }
Пример #58
0
        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);
        }
Пример #59
0
        public void CalculatedTileWeights_PathedAndUnpathedLayer_UnpathedLayerOccupied_ClearsPathing()
        {
            // Arrange
            var testHex        = new Hex(2, 3);
            var pathedMapLayer = new PathedMapLayer <bool>();

            pathedMapLayer[testHex] = new PathedTile <bool>(true, 3, true);

            var unpathedMapLayer = new MapLayer <bool>();

            unpathedMapLayer[testHex] = true;

            var map = new LayeredMap(LayoutOrientation.Flat, new Vector2(10, 10), new Vector2(100, 100), pathedMapLayer);

            map.AddLayer(unpathedMapLayer);

            // Act
            var pathingInfo = map.CalculatedTileWeights();

            // Assert
            Assert.IsTrue(!pathingInfo.ContainsKey(testHex));
        }
Пример #60
0
        private void DrawMapMarker(GeoCoordinate coordinate, Color color, MapLayer mapLayer)
        {
            // Create a map marker
            Polygon polygon = new Polygon();

            polygon.Points.Add(new Point(0, 0));
            polygon.Points.Add(new Point(0, 75));
            polygon.Points.Add(new Point(25, 0));
            polygon.Fill = new SolidColorBrush(color);

            // Enable marker to be tapped for location information
            polygon.Tag = new GeoCoordinate(coordinate.Latitude, coordinate.Longitude);
            // polygon.MouseLeftButtonUp += new MouseButtonEventHandler(Marker_Click);

            // Create a MapOverlay and add marker
            MapOverlay overlay = new MapOverlay();

            overlay.Content        = polygon;
            overlay.GeoCoordinate  = new GeoCoordinate(coordinate.Latitude, coordinate.Longitude);
            overlay.PositionOrigin = new Point(0.0, 1.0);
            mapLayer.Add(overlay);
        }