public static SharpMap.Map InitializeGoogleMap(GoogleMapType mt) { SharpMap.Map map = new SharpMap.Map(); GoogleRequest req; ITileSource tileSource; TileAsyncLayer tileLayer; if (mt == (GoogleMapType.GoogleSatellite | GoogleMapType.GoogleLabels)) { req = new GoogleRequest(GoogleMapType.GoogleSatellite); tileSource = new GoogleTileSource(req); tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + GoogleMapType.GoogleSatellite); map.Layers.Add(tileLayer); req = new GoogleRequest(GoogleMapType.GoogleLabels); tileSource = new GoogleTileSource(req); mt = GoogleMapType.GoogleLabels; } else { req = new GoogleRequest(mt); tileSource = new GoogleTileSource(req); } tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + mt); map.BackgroundLayer.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return(map); }
/// <summary> /// Converts GoogleMapType enum value to parameter string /// </summary> /// <param name="mapType">The map type enum value.</param> /// <returns>Parameter string for the given map type</returns> public static string GetGoogleMapTypeString(GoogleMapType mapType) { switch (mapType) { case (GoogleMapType.RoadMap): { return("roadmap"); } case (GoogleMapType.Satellite): { return("satellite"); } case (GoogleMapType.Terrain): { return("terrain"); } case (GoogleMapType.Hybrid): { return("hybrid"); } default: { return("roadmap"); } } }
private static Map InitializeMapGoogle(GoogleMapType mt) { Map map = new Map(); GoogleRequest req; ITileSource tileSource; TileLayer tileLayer; if (mt == (GoogleMapType.GoogleSatellite | GoogleMapType.GoogleLabels)) { req = new GoogleRequest(GoogleMapType.GoogleSatellite); tileSource = new GoogleTileSource(req); tileLayer = new TileLayer(tileSource, "TileLayer - " + GoogleMapType.GoogleSatellite); map.Layers.Add(tileLayer); req = new GoogleRequest(GoogleMapType.GoogleLabels); tileSource = new GoogleTileSource(req); mt = GoogleMapType.GoogleLabels; } else { req = new GoogleRequest(mt); tileSource = new GoogleTileSource(req); } tileLayer = new TileLayer(tileSource, "TileLayer - " + mt); map.Layers.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return(map); }
public static SharpMap.Map InitializeGoogleMap(GoogleMapType mt) { SharpMap.Map map = new SharpMap.Map(); GoogleRequest req; ITileSource tileSource; TileAsyncLayer tileLayer; if (mt == (GoogleMapType.GoogleSatellite | GoogleMapType.GoogleLabels)) { req = new GoogleRequest(GoogleMapType.GoogleSatellite); tileSource = new GoogleTileSource(req); tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + GoogleMapType.GoogleSatellite); map.Layers.Add(tileLayer); req = new GoogleRequest(GoogleMapType.GoogleLabels); tileSource = new GoogleTileSource(req); mt = GoogleMapType.GoogleLabels; } else { req = new GoogleRequest(mt); tileSource = new GoogleTileSource(req); } tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + mt); map.BackgroundLayer.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return map; }
/// <summary> /// Initializes the url builder. /// </summary> /// <param name="width">Width of the map in pixels.</param> /// <param name="height">Height of the map in pixels.</param> /// <param name="mapType">Type of the map.</param> public GoogleStaticMapUrlBuilder(int width, int height, GoogleMapType mapType) { Width = width; Height = height; MapType = mapType; Markers = new List<MapMarker>(); Paths = new List<MapPath>(); }
/// <summary> /// Constructor a new GoogleMapOption structure /// </summary> public GoogleMapOption(LatLng center, GoogleMapType type = GoogleMapType.Roadmap, int zoomLevel = 10, bool visibleZoomControl = false, bool enableGesture = true, ZoomControlPosition controlPosition = ZoomControlPosition.RightBottom) { Center = center; MapType = type; _zoom = Math.Min(Math.Max(zoomLevel, 1.0), 20.0);; IsZoomControlVisible = visibleZoomControl; HasGestureEnabled = enableGesture; ZoomControlPosition = controlPosition; }
// Set the selected item of the box to the provided value private void SetMapType(ComboBox box, GoogleMapType mapTye) { foreach (var item in box.Items) { var boxItem = item as ComboBoxItem; if (boxItem != null && (GoogleMapType)boxItem.Tag == mapTye) { box.SelectedItem = item; return; } } }
public GoogleMapsOptions MapType(GoogleMapType mapType) { if (GoogleMapUtils.IsPlatformNotSupported) { return(this); } if (GoogleMapUtils.IsAndroid) { _ajo.CallAJO(MapTypeMethodName, (int)mapType); } else { _dic[MapTypeMethodName] = (int)mapType; } return(this); }
/// <summary> /// Returns the string representation of the provided map type. /// </summary> /// <param name="mapType">The map type to get the string reprentation for.</param> /// <returns>The string representation of the provided map type</returns> public static string GetMapTypeString(GoogleMapType mapType) { switch (mapType) { case GoogleMapType.Hybrid: return("hybrid"); case GoogleMapType.Road: return("roadmap"); case GoogleMapType.Satellite: return("satellite"); case GoogleMapType.Terrain: return("terrain"); default: return("roadmap"); } }
public async Task <byte[]> GetMapAsync(float latitude, float longitude, int zoom, int scale, int width, int height, GoogleMapType mapType, GoogleImageFormat format, IList <TrackCoordinate> trackCoordinates) { byte[] bitmap = null; try { var requestUri = string.Empty; for (int i = _resolutionModifierStep; i <= _maxResolutionModifierStep; i++) { if (i > _resolutionModifierStep) { _logger.LogTrace($"Attempting to build Track Map requestUri at resolution of {i}"); } string pathParameter = BuildMapPath(trackCoordinates, i); requestUri = string.Format( "https://maps.googleapis.com/maps/api/staticmap?&scale=1center={0}&zoom={1}&size={2}&maptype={3}&format={4}&key={5}{6}", $"{latitude},{longitude}", zoom, $"{width}x{height}", GoogleMapHelper.GetGoogleMapTypeString(mapType), GoogleMapHelper.GetGoogleFormatString(format), GoogleMapHelper.ApiKey, pathParameter); if (requestUri.Length < 8192) { break; } else if (requestUri.Length > 8192 && i >= _maxResolutionModifierStep) { throw new InvalidOperationException($"requestUri too long: {requestUri.Length}"); } } _logger.LogTrace($"Google Maps requestUri: {requestUri}"); using (WebClient wc = new WebClient()) { bitmap = await wc.DownloadDataTaskAsync(new Uri(requestUri)); } } catch (Exception ex) { _logger.LogError(ex, "Exception in GetMapAsync"); throw; } return(bitmap); }
public GoogleTileSource(GoogleMapType mapType) : this(new GoogleRequest(mapType), new NullCache()) { }
public GoogleTileSource(GoogleMapType mapType) : this(new GoogleRequest(mapType)) { }
public GoogleRequest(GoogleMapType googleMapType) : this(googleMapType, LanguageType.English) { }
public GoogleRequest(GoogleMapType googleMapType, LanguageType languageType) { Language = languageType; MapType = googleMapType; }
public string GetMapUri(float latitude, float longitude, int zoom, int scale, int width, int height, GoogleMapType mapType, GoogleImageFormat format) { return(GetMapUri(latitude, longitude, zoom, scale, width, height, mapType, format, null)); }
/// <summary> /// Creates a control for creating an url for Google Static Maps. /// </summary> /// <param name="url">The Url helper instance that this method extends.</param> /// <param name="width">Width of the image in pixels.</param> /// <param name="height">Height of the image in pixels.</param> /// <param name="mapType">Type of map.</param> /// <returns>A control that allows further configuration of the map.</returns> public static GoogleStaticMapControl GoogleStaticMap(this UrlHelper url, int width, int height, GoogleMapType mapType) { return new GoogleStaticMapControl(width, height, mapType) .AsUrl(); }
/// <summary> /// Creates a control for creating an img tag for Google Static Maps. /// </summary> /// <param name="html">The HTML helper instance that this method extends.</param> /// <param name="width">Width of the image in pixels.</param> /// <param name="height">Height of the image in pixels.</param> /// <param name="mapType">Type of map.</param> /// <param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param> /// <returns>A control that allows further configuration of the map.</returns> public static GoogleStaticMapControl GoogleStaticMap(this HtmlHelper html, int width, int height, GoogleMapType mapType, object htmlAttributes) { return new GoogleStaticMapControl(width, height, mapType) .AsImage(htmlAttributes); }
/// <summary> /// Creates a control for creating an img tag for Google Static Maps. /// </summary> /// <param name="html">The HTML helper instance that this method extends.</param> /// <param name="width">Width of the image in pixels.</param> /// <param name="height">Height of the image in pixels.</param> /// <param name="mapType">Type of map.</param> /// <returns>A control that allows further configuration of the map.</returns> public static GoogleStaticMapControl GoogleStaticMap(this HtmlHelper html, int width, int height, GoogleMapType mapType) { return GoogleStaticMap(html, width, height, mapType, null); }
public string GetMapUri(float latitude, float longitude, int zoom, int scale, int width, int height, GoogleMapType mapType, GoogleImageFormat format, IList <TrackCoordinate> trackCoordinates) { var requestUri = string.Empty; for (int i = _resolutionModifierStep; i <= _maxResolutionModifierStep; i++) { if (i > _resolutionModifierStep) { _logger.LogTrace($"Attempting to build Track Map requestUri at resolution of {i}"); } string pathParameter = BuildMapPath(trackCoordinates, i); requestUri = string.Format( "https://maps.googleapis.com/maps/api/staticmap?center={0}&zoom={1}&size={2}&maptype={3}&format={4}{5}&key={6}", $"{latitude},{longitude}", zoom, $"{width}x{height}", GoogleMapHelper.GetGoogleMapTypeString(mapType), GoogleMapHelper.GetGoogleFormatString(format), pathParameter, GoogleMapHelper.ApiKey); if (requestUri.Length < 8192) { break; } else if (requestUri.Length > 8192 && i >= _maxResolutionModifierStep) { throw new InvalidOperationException($"requestUri too long: {requestUri.Length}"); } } return(requestUri); }
private static Map InitializeMapGoogle(GoogleMapType mt) { Map map = new Map(); GoogleRequest req; ITileSource tileSource; TileLayer tileLayer; if (mt == (GoogleMapType.GoogleSatellite | GoogleMapType.GoogleLabels)) { req = new GoogleRequest(GoogleMapType.GoogleSatellite); tileSource = new GoogleTileSource(req); tileLayer = new TileLayer(tileSource, "TileLayer - " + GoogleMapType.GoogleSatellite); map.Layers.Add(tileLayer); req = new GoogleRequest(GoogleMapType.GoogleLabels); tileSource = new GoogleTileSource(req); mt = GoogleMapType.GoogleLabels; } else { req = new GoogleRequest(mt); tileSource = new GoogleTileSource(req); } tileLayer = new TileLayer(tileSource, "TileLayer - " + mt); map.Layers.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return map; }
/// <summary> /// Initializes the control. /// </summary> /// <param name="html">The HTML helper instance that this method extends.</param> /// <param name="width">Width of the image in pixels.</param> /// <param name="height">Height of the image in pixels.</param> /// <param name="mapType">Type of map.</param> public GoogleStaticMapControl(int width, int height, GoogleMapType mapType) { _urlBuilder = new GoogleStaticMapUrlBuilder(width, height, mapType); _renderMode = RenderMode.Image; }