예제 #1
0
        private void refreshMap()
        {
            if (resultsTreeView.SelectedItem == null)
            {
                return;
            }

            var location = ((LatLng)((TreeViewItem)resultsTreeView.SelectedItem).Tag);

            var map = new StaticMapRequest
            {
                Center  = location,
                Zoom    = Convert.ToInt32(zoomSlider.Value),
                Size    = new MapSize(332, 332),
                MapType = (MapTypes)Enum.Parse(typeof(MapTypes), ((ComboBoxItem)mapTypeComboBox.SelectedItem).Content.ToString(), true)
            };

            map.Markers.Add(map.Center);

            var mapSvc = new StaticMapService();

            using (var ms = new System.IO.MemoryStream(mapSvc.GetImage(map)))
            {
                var image = new BitmapImage();
                image.BeginInit();
                image.StreamSource = mapSvc.GetStream(map);
                image.CacheOption  = BitmapCacheOption.OnLoad;
                image.EndInit();
                image1.Source = image;
            }
        }
예제 #2
0
        public void CreateAllTripMaps()
        {
            ApplicationSettings.Default.Reload();
            var k = ApplicationSettings.Default.MapQuestKey;

            ApplicationSettings.Default.PropertyValues["MapQuestKey"].PropertyValue = "";
            k = ApplicationSettings.Default.MapQuestKey;



            StaticMapService.CreateAllTripMaps(StaticMapProvider.MapMode.Dark);

            var inst = StaticMapService.GetSingleton();

            Thread threadStaticMapService = new Thread(() =>
            {
                StaticMapService.GetSingleton().Run();
            })
            {
                Name = "StaticMapServiceThread"
            };

            threadStaticMapService.Start();

            while (inst.GetQueueLength() > 0)
            {
                System.Threading.Thread.Sleep(500);
            }
        }
예제 #3
0
        private void refreshMap(Location location, Image imageControl)
        {
            var request = new StaticMapRequest
            {
                Center  = location,
                Zoom    = Convert.ToInt32(zoomSlider.Value),
                Size    = new MapSize(Convert.ToInt32(imageControl.Width), Convert.ToInt32(imageControl.Height)),
                MapType = (MapTypes)Enum.Parse(typeof(MapTypes), ((ComboBoxItem)mapTypeComboBox.SelectedItem).Content.ToString(), true)
            };

            request.Markers.Add(request.Center);

            var mapSvc = new StaticMapService();

            var imageSource = new BitmapImage();

            imageSource.BeginInit();

            imageSource.StreamSource = mapSvc.GetStream(request);
            imageSource.CacheOption  = BitmapCacheOption.OnLoad;

            imageSource.EndInit();

            imageControl.Source = imageSource;
        }
예제 #4
0
        public void CreateAllTripMapsMapQuest()
        {
            if (String.IsNullOrEmpty(Settings.Default.MapQuestKey))
            {
                Assert.Inconclusive("No Settings for MapQuestKey");
            }

            ApplicationSettings.Default.Reload();
            var k = ApplicationSettings.Default.MapQuestKey;

            ApplicationSettings.Default.PropertyValues["MapQuestKey"].PropertyValue = Settings.Default.MapQuestKey;

            k = ApplicationSettings.Default.MapQuestKey;

            StaticMapService.CreateAllTripMaps(StaticMapProvider.MapMode.Dark);

            var inst = StaticMapService.GetSingleton();

            Thread threadStaticMapService = new Thread(() =>
            {
                StaticMapService.GetSingleton().Run();
            })
            {
                Name = "StaticMapServiceThread"
            };

            threadStaticMapService.Start();

            while (inst.GetQueueLength() > 0)
            {
                System.Threading.Thread.Sleep(500);
            }
        }
예제 #5
0
        public BitmapImage GenerateMap(string address)
        {
            GoogleSigned.AssignAllServices(new GoogleSigned(API_KEY));
            var map = new StaticMapRequest();

            map.Center = new Location(address);
            map.Size   = new System.Drawing.Size(400, 400);
            map.Zoom   = 14;

            StaticMapService staticMapService = new StaticMapService();
            BitmapImage      img = new BitmapImage();

            img.StreamSource = staticMapService.GetStream(map);
            return(img);
        }
예제 #6
0
        public async Task <Image> MakeMap()
        {
            List <Google.Maps.Location> gLocations = locations.Select(loc => new Google.Maps.Location($"{loc.latitude}, {loc.longitude}")).ToList();
            StaticMapService            service    = new StaticMapService();
            StaticMapRequest            map        = new StaticMapRequest();

            map.Path        = new Path(gLocations);
            map.Path.Weight = 10;
            map.Path.Encode = false;
            map.Format      = GMapsImageFormats.PNG;
            map.MapType     = MapTypes.Terrain;
            map.Size        = new MapSize(1920, 1080);

            return((Image) new ImageConverter().ConvertFrom(await service.GetImageAsync(map)));
        }
예제 #7
0
        public void CreateAllChargingMaps()
        {
            StaticMapService.CreateAllChargingMaps();

            var inst = StaticMapService.GetSingleton();

            Thread threadStaticMapService = new Thread(() =>
            {
                StaticMapService.GetSingleton().Run();
            })
            {
                Name = "StaticMapServiceThread"
            };

            threadStaticMapService.Start();

            while (inst.GetQueueLength() > 0)
            {
                System.Threading.Thread.Sleep(500);
            }
        }
        async Task SearchAddressAsync(string text)
        {
            searchBoxError          = false;
            searchTextBox.ForeColor = Color.Black;

            var cachedImage = DataSource.GetCachedImage(text, currentZoom, MapType);

            if (cachedImage != null)
            {
                pictureBox.Image = cachedImage;
                return;
            }

            var staticMapsRequest = new StaticMapRequest
            {
                Center  = new Location(text),
                Size    = new MapSize(600, 600),
                Zoom    = currentZoom,
                MapType = MapType
            };
            var staticMapsService = new StaticMapService();

            var byteArray = await staticMapsService.GetImageAsync(staticMapsRequest);

            var    errorHash = "6i62JfRBdd+DQcwx5Q0p4MpeYWI=";
            string hash      = Utils.CulculateSHA1Hash(byteArray);

            DataSource.CacheImage(text, currentZoom, MapType, byteArray);

            if (hash == errorHash)
            {
                searchBoxError          = true;
                searchTextBox.ForeColor = Color.Red;
                return;
            }

            pictureBox.Image = Utils.BytesArrayToBitmap(byteArray);
        }