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))); }
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); }