// Initial batch uodate private void addAllPins() { if (xMap.pins == null) { return; } // Subscribe all pins to their respective changes foreach (var pin in xMap.pins) { pin.PropertyChanged += Pin_PropertyChanged; } // Add the mapLocked pins first // Select all pins where it has heading setter activated var mapLockedFeatureCollection = xMap.pins.Where((Pin pin) => pin.IsCenterAndFlat).toFeatureCollection(); var mapLockedGeoJsonSource = new GeoJsonSource(mapLockedPinsSourceKey, mapLockedFeatureCollection); nMap.AddSource(mapLockedGeoJsonSource); // Add the normal pins after // Select all pins where it has heading disabled var normalFeatureCollection = xMap.pins.Where((Pin pin) => !pin.IsCenterAndFlat).toFeatureCollection(); var normalGeoJsonSource = new GeoJsonSource(normalPinsSourceKey, normalFeatureCollection); nMap.AddSource(normalGeoJsonSource); }
private void HandleStyleLoaded(MapStyle obj) { var routeCoordinates = GetCoords(); var source = new GeoJsonSource { Id = "line.src", Data = new FeatureCollection( new List <Feature> { new Feature(new LineString(routeCoordinates.Select(x => new Position(x.Lat, x.Long)))) }) }; map.Functions.AddSource(source); var layer = new LineLayer("line.layer", source.Id) { LineDasharray = Expression.Literal(new[] { 0.01f, 2f }), LineCap = Expression.Literal("round"), LineJoin = Expression.Literal("round"), LineWidth = Expression.Literal(5f), LineColor = Expression.Color(Color.FromHex("#e55e5e")) }; map.Functions.AddLayer(layer); }
private void HandleStyleLoaded(MapStyle obj) { var source = new GeoJsonSource(GEOJSON_SRC_ID, "asset://poi_places.geojson") { IsLocal = true }; map.Functions.AddSource(source); var layer = new SymbolLayer(POI_LABELS_LAYER_ID, GEOJSON_SRC_ID) { TextField = Expression.Get("description"), TextSize = 17f, TextColor = Color.Red, TextVariableAnchor = new [] { LayerProperty.TEXT_ANCHOR_TOP, LayerProperty.TEXT_ANCHOR_BOTTOM, LayerProperty.TEXT_ANCHOR_LEFT, LayerProperty.TEXT_ANCHOR_RIGHT }, TextJustify = LayerProperty.TEXT_JUSTIFY_AUTO, TextRadialOffset = 0.5f }; map.Functions.AddLayer(layer); }
private void HandleStyleLoaded(MapStyle obj) { try { if (outter_points.Count >= 4) { var polygon = new Polygon(points.Select(x => x.Select(y => new[] { y.Longitude, y.Latitude }))); var layer = new FillLayer("layer-id", "source-id") { FillColor = Color.FromHex("#FF0000") }; var source = new GeoJsonSource("source-id", new Feature(polygon)); if (map.Functions.GetLayers().Count() > 0) { map.Functions.RemoveSource("source-id"); map.Functions.RemoveLayer("settlement-label"); } map.Functions.AddSource(source); map.Functions.AddLayerBelow(layer, "settlement-label"); } else { DisplayAlert(null, "You have less than 4 points", "OK"); } } catch (Exception ex) { } }
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); }
private void AddDataToMap(FeatureCollection featureCollection) { // Retrieves GeoJSON from local file and adds it to the map var geoJsonSource = new GeoJsonSource(GEOJSON_SRC_ID, featureCollection); map.Functions.AddSource(geoJsonSource); InitTemperatureLayers(); PopulateMenu(); // show Connecticut by default int indexOfState = IndexOfState("Connecticut"); SelectState(states[indexOfState].name, indexOfState); }
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); }
private void addAllRoutes() { if (xMap.routes == null) { return; } // Subscribe all routes to their respective changes foreach (var route in xMap.routes) { route.PropertyChanged += Route_PropertyChanged; } var geoJsonSource = new GeoJsonSource(line_source_key, xMap.routes.toFeatureCollection()); nMap.AddSource(geoJsonSource); }
private void HandleStyleLoaded(MapStyle obj) { var courseRouteGeoJson = new GeoJsonSource( "coursedata", "asset://marathon_route.geojson") { IsLocal = true }; map.Functions.ShowTraffic(visible); // Add FillExtrusion layer to map using GeoJSON data map.Functions.AddLayer(new FillExtrusionLayer("course", "coursedata") { FillExtrusionColor = Color.Yellow, FillExtrusionOpacity = 0.7f, FillExtrusionHeight = Expression.Get("e") }); }
private void HandleStyleLoaded(MapStyle obj) { var source = new GeoJsonSource { Id = "urban-areas", Url = "https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_50m_urban_areas.geojson" }; map.Functions.AddSource(source); var layer = new FillLayer("urban-areas-fill", source.Id) { FillColor = Color.FromHex("#ff0088"), FillOpacity = 0.4f }; map.Functions.AddLayerBelow(layer, "water"); }
private void HandleStyleLoaded(MapStyle obj) { // Add Features which represent the location of each profile photo SymbolLayer icon Feature carlosFeature = new Feature(new GeoJSON.Net.Geometry.Point(new Position(41.2778064, -7.9760742))); carlosFeature.Properties.Add(PROFILE_NAME, CARLOS); Feature antonyFeature = new Feature(new GeoJSON.Net.Geometry.Point(new Position(37.5445773, -8.0639648 ))); antonyFeature.Properties.Add(PROFILE_NAME, ANTONY); Feature mariaFeature = new Feature(new GeoJSON.Net.Geometry.Point(new Position(38.9764924, -9.1845703 ))); mariaFeature.Properties.Add(PROFILE_NAME, MARIA); Feature lucianaFeature = new Feature(new GeoJSON.Net.Geometry.Point(new Position(40.2459915, -7.5146484))); lucianaFeature.Properties.Add(PROFILE_NAME, LUCIANA); var source = new GeoJsonSource(ICON_SOURCE_ID, new FeatureCollection(new List <Feature> { carlosFeature, antonyFeature, mariaFeature, lucianaFeature })); map.Functions.AddSource(source); map.Functions.AddLayer(new SymbolLayer(ICON_LAYER_ID, ICON_SOURCE_ID) { IconImage = Expression.Get(PROFILE_NAME), IconIgnorePlacement = true, IconAllowOverlap = true, TextField = Expression.Get(PROFILE_NAME), TextIgnorePlacement = true, TextAllowOverlap = true, TextOffset = new[] { 0f, 2f } }); }
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); }
private void Map() { try { polygon = new Polygon( points.Select(x => x.Select(y => new[] { y.Longitude, y.Latitude })) ); var layer = new FillLayer("layer-id", "source-id") { FillColor = Color.FromHex("#FF0000") }; var source = new GeoJsonSource("source-id", new Feature(polygon)); if (map.Functions.GetLayers().Count() > 0) { DisplayAlert(null, "Layers found", "OK"); map.Functions.RemoveSource("source-id"); map.Functions.RemoveLayer("settlement-label"); DisplayAlert(null, "Layers removed", "OK"); } else { DisplayAlert(null, "No layers found", "OK"); } map.Functions.AddSource(source); map.Functions.AddLayerBelow(layer, "settlement-label"); DisplayAlert(null, "Done Mapping", "OK"); } catch (Exception ex) { DisplayAlert(null, ex.Message, "OK"); } }
/** * Adds the GeoJSON source to the map */ private void SetupSource() { source = new GeoJsonSource(GEOJSON_SOURCE_ID, featureCollection); map.Functions.AddSource(source); }