public void AddStyleImage(IconImageSource iconImageSource) { if (iconImageSource.Source == null) { return; } var cachedImage = mapStyle.ImageForName(iconImageSource.Id); if (cachedImage != null) { return; } var image = iconImageSource.Source.GetImage(); if (image == null) { return; } if (iconImageSource.IsTemplate) { image = image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); } mapStyle.SetImage(image, iconImageSource.Id); }
protected override async void OnAttached() { ImageSource source = null; if (!string.IsNullOrWhiteSpace(Effect.Icon) && IconFontRegistry.Instance.TryFindIconForKey(Effect.Icon, out var _)) { source = new IconImageSource { Color = Effect.LineColor, Name = Effect.Icon, Size = Effect.ImageWidth }; } else if (Effect.ImageSource != null) { source = Effect.ImageSource; } else { return; } var handler = Xamarin.Forms.Internals.Registrar.Registered.GetHandlerForObject <IImageSourceHandler>(source); if (handler != null) { var bitmap = await handler.LoadImageAsync(source, Container.Context); SetImageOnEntry(new BitmapDrawable(Container.Context.Resources, bitmap)); } }
protected override async void OnAttached() { ImageSource source; if (!string.IsNullOrWhiteSpace(Effect.Icon) && FontRegistry.HasFont(Effect.Icon, out _)) { source = new IconImageSource { Color = Effect.LineColor, Name = Effect.Icon, Size = Effect.ImageWidth }; } else if (Effect.ImageSource != null) { source = Effect.ImageSource; } else { return; } var handler = Xamarin.Forms.Internals.Registrar.Registered.GetHandlerForObject <IImageSourceHandler>(source); if (handler != null) { SetImage(await handler.LoadImageAsync(source)); } }
private void HandleStyleLoaded(MapStyle obj) { map.Center = new LatLng(double.Parse((this.BindingContext as CalculateViewModel).Lat), double.Parse((this.BindingContext as CalculateViewModel).Lon)); iconImageSource = (ImageSource)"RE.png"; markerImageSource = (ImageSource)"Marker.png"; map.Functions.AddStyleImage(iconImageSource); map.Functions.AddStyleImage(markerImageSource); featureCollection = new FeatureCollection(symbolLayerIconFeatureList); markerCollection = new FeatureCollection(markerLayerIconFeatureList); source = new GeoJsonSource { Id = "feature.memory.src", Data = featureCollection }; markerSource = new GeoJsonSource { Id = "feature.marker.src", Data = markerCollection }; map.Functions.AddSource(source); map.Functions.AddSource(markerSource); symbolLayer = new SymbolLayer("feature.symbol.layer", source.Id) { IconAllowOverlap = Expression.Literal(true), IconImage = Expression.Literal(iconImageSource.Id), IconOffset = Expression.Literal(new[] { -5, -5 }), IconSize = Expression.Literal(0.7) }; markerLayer = new SymbolLayer("feature.marker.layer", markerSource.Id) { IconAllowOverlap = Expression.Literal(true), IconImage = Expression.Literal(markerImageSource.Id), IconOffset = Expression.Literal(new[] { -5, -5 }), IconSize = Expression.Literal(0.2) }; map.Functions.AddLayer(symbolLayer); map.Functions.AddLayer(markerLayer); var feature = new Feature(new GeoJSON.Net.Geometry.Point(new Position( (this.BindingContext as CalculateViewModel).Lat, (this.BindingContext as CalculateViewModel).Lon))); symbolLayerIconFeatureList.Add(feature); featureCollection = new FeatureCollection(symbolLayerIconFeatureList); map.Functions.UpdateSource(source.Id, featureCollection); }
/// <summary> /// Sets the icon image source /// </summary> public void SetIconImageSource() { try { IconImageSource = IconSource == null ? null : WindowsHelpers.GetIconOrThumbnail(IconSource, ShellThumbnailSize.Small).ToImageSource(); IconImageSource?.Freeze(); } catch (Exception ex) { Logger.Warn(ex, "Getting jump list icon image source"); } }
public override int GetHashCode() { // It does not metter int overflow unchecked { // Choose large primes to avoid hashing collisions const int HASHING_BASE = (int)2166136261; const int HASHING_MULTIPLIER = 16777619; int hash = HASHING_BASE; hash *= HASHING_MULTIPLIER + ((Title is null) ? 0 : Title.GetHashCode()); hash *= HASHING_MULTIPLIER + ((AutomationId is null) ? 0 : AutomationId.GetHashCode()); hash *= HASHING_MULTIPLIER + ((IconImageSource is null) ? 0 : IconImageSource.GetHashCode()); return(hash); } }
private void HandleStyleLoaded(MapStyle obj) { var fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite") { SourceLayer = "building", Filter = Expression.Eq(Expression.Get("extrude"), "true"), MinZoom = 10, FillExtrusionColor = Color.LightGray, FillExtrusionHeight = Expression.Interpolate( Expression.Exponential(1f), Expression.Zoom(), Expression.CreateStop(15, (0)), Expression.CreateStop(16, Expression.Get("height")) ), FillExtrusionBase = Expression.Get("min_height"), FillExtrusionOpacity = 0.9f }; //map.Functions.AddLayer(fillExtrusionLayer); map.Functions.AnimateCamera(map.Camera, 1000); iconImageSource = (ImageSource)"RE.png"; map.Functions.AddStyleImage(iconImageSource); featureCollection = new FeatureCollection(symbolLayerIconFeatureList); source = new GeoJsonSource { Id = "feature.memory.src", Data = featureCollection }; map.Functions.AddSource(source); symbolLayer = new SymbolLayer("feature.symbol.layer", source.Id) { IconAllowOverlap = Expression.Literal(true), IconImage = Expression.Literal(iconImageSource.Id), IconOffset = Expression.Literal(new[] { -5, -5 }), IconSize = Expression.Literal(0.7) }; map.Functions.AddLayer(symbolLayer); map.DidTapOnMapCommand = new Command <(LatLng position, Point point)>(HandleMapTapped); }
void HandleStyleLoaded(MapStyle obj) { IconImageSource iconImageSource = ImageSource.FromFile("red_marker.png"); /*map.Functions.AddStyleImage(iconImageSource); * * var symbolLayerIconFeatureList = new List<Feature>(); * symbolLayerIconFeatureList.Add( * new Feature(new GeoJSON.Net.Geometry.Point( * new GeoJSON.Net.Geometry.Position(-33.213144, -57.225365)))); * symbolLayerIconFeatureList.Add( * new Feature(new GeoJSON.Net.Geometry.Point( * new GeoJSON.Net.Geometry.Position(-33.981818, -54.14164)))); * symbolLayerIconFeatureList.Add( * new Feature(new GeoJSON.Net.Geometry.Point( * new GeoJSON.Net.Geometry.Position(-30.583266, -56.990533)))); * * var featureCollection = new FeatureCollection(symbolLayerIconFeatureList); * * var source = new GeoJsonSource * { * Id = "feature.memory.src", * Data = featureCollection * }; * map.Functions.AddSource(source); * * var symbolLayer = new SymbolLayer("feature.symbol.layer", source.Id) * { * IconAllowOverlap = Expression.Literal(true), * IconImage = Expression.Literal(iconImageSource.Id), * IconOffset = Expression.Literal(new[] { 0.0, -9.0 }) * }; * map.Functions.AddLayer(symbolLayer);*/ var symbol = new SymbolAnnotation { Coordinates = new LatLng(60.169091, 24.939876), IconImage = iconImageSource, IconSize = 2.0f, IsDraggable = true, Id = Guid.NewGuid().ToString() }; map.Annotations = new[] { symbol }; }
void HandleStyleLoaded(MapStyle obj) { var fisrtPoint = lineString.Coordinates[0]; map.Center = new LatLng(fisrtPoint.Latitude, fisrtPoint.Longitude); IconImageSource icon = (ImageSource)"pink_dot.png"; map.Functions.AddStyleImage(icon); map.Functions.AddSource(new GeoJsonSource() { Id = lineSourceId, Data = new FeatureCollection() }); var routeLayer = new LineLayer("trip.layer", lineSourceId) { LineColor = Expression.Color(Color.FromHex("#F13C6E")), LineCap = Expression.Literal("round"), LineJoin = Expression.Literal("round"), LineWidth = Expression.Literal(4.0f) }; map.Functions.AddLayerBelow(routeLayer, "road-label"); map.Functions.AddSource(new GeoJsonSource() { Id = dotSourceId, Data = new Feature(new GeoJSON.Net.Geometry.Point(fisrtPoint)) }); var dotLayer = new SymbolLayer("dot.layer", dotSourceId) { IconImage = Expression.Literal(icon.Id), IconSize = Expression.Literal(0.5f), IconOffset = Expression.Literal(new[] { 5, 0 }), IconIgnorePlacement = Expression.Literal(true), IconAllowOverlap = Expression.Literal(true) }; map.Functions.AddLayer(dotLayer); Animate(); }
void HandleStyleLoaded(MapStyle obj) { IconImageSource iconImageSource = (ImageSource)"red_marker.png"; map.Functions.AddStyleImage(iconImageSource); var symbolLayerIconFeatureList = new List <Feature>(); symbolLayerIconFeatureList.Add( new Feature(new GeoJSON.Net.Geometry.Point( new GeoJSON.Net.Geometry.Position(-33.213144, -57.225365)))); symbolLayerIconFeatureList.Add( new Feature(new GeoJSON.Net.Geometry.Point( new GeoJSON.Net.Geometry.Position(-33.981818, -54.14164)))); symbolLayerIconFeatureList.Add( new Feature(new GeoJSON.Net.Geometry.Point( new GeoJSON.Net.Geometry.Position(-30.583266, -56.990533)))); var featureCollection = new FeatureCollection(symbolLayerIconFeatureList); var source = new GeoJsonSource { Id = "feature.memory.src", Data = featureCollection }; map.Functions.AddSource(source); var symbolLayer = new SymbolLayer("feature.symbol.layer", source.Id) { IconAllowOverlap = Expression.Literal(true), IconImage = Expression.Literal(iconImageSource.Id), IconOffset = Expression.Literal(new[] { 0.0, -9.0 }) }; map.Functions.AddLayer(symbolLayer); }