Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Clear the default layer, add a dark one instead
            MapView.Layers.Clear();
            MapView.Layers.Add(new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDark));

            Projection projection = MapView.Options.BaseProjection;

            // Create a datasource and layer for the map
            LocalVectorDataSource source = new LocalVectorDataSource(projection);
            VectorLayer           layer  = new VectorLayer(source);

            MapView.Layers.Add(layer);

            // Initialize CartoSQL service, set a username
            CartoSQLService service = new CartoSQLService();

            service.Username = "******";

            PointStyleBuilder builder = new PointStyleBuilder
            {
                Color = new Carto.Graphics.Color(255, 0, 0, 255),
                Size  = 1
            };

            MapView.QueryFeatures(service, source, builder.BuildStyle(), query);
        }
Example #2
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleVoyager);

            // Initialize source and Edit layer, add it to the map
            source = new LocalVectorDataSource(MapView.Options.BaseProjection);

            editLayer = new EditableVectorLayer(source);
            MapView.Layers.Add(editLayer);

            // Convenience methods to add elements to the map, cf. LocalVectorDataSourceExtensions
            source.AddPoint(new MapPos(-5000000, -900000));

            source.AddLine(new MapPosVector {
                new MapPos(-6000000, -500000), new MapPos(-9000000, -500000)
            });

            source.AddPolygon(new MapPosVector {
                new MapPos(-5000000, -5000000), new MapPos(5000000, -5000000), new MapPos(0, 10000000)
            });

            // Add a vector element event listener to select elements (on element click)
            editLayer.VectorElementEventListener = new VectorElementSelectEventListener(editLayer);

            // Add a map event listener to deselect element (on map click)
            MapView.MapEventListener = new VectorElementDeselectEventListener(editLayer);

            // Add the vector element edit event listener
            editLayer.VectorEditEventListener = new BasicEditEventListener(source);

            Alert("Click on object to modify or move it");
        }
Example #3
0
        public static void AddBalloonPopup1(LocalVectorDataSource source, Projection projection, Bitmap leftImage, Bitmap rightImage)
        {
            // TODO REMOVE WHEN ANDROID COMPLETE
            //Bitmap infoImage = BitmapFactory.decodeResource(getResources(), R.drawable.info);
            //Bitmap arrowImage = BitmapFactory.decodeResource(getResources(), R.drawable.arrow);

            //BitmapUtils.createBitmapFromAndroidBitmap(infoImage)
            //BitmapUtils.createBitmapFromAndroidBitmap(arrowImage);

            // Add popup
            BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder();

            builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6);
            builder.LeftImage   = leftImage;

            builder.RightImage   = rightImage;
            builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6);

            builder.CornerRadius      = 20;
            builder.PlacementPriority = 1;

            MapPos       position = projection.FromWgs84(new MapPos(24.655662, 59.425521));
            BalloonPopup popup1   = new BalloonPopup(position, builder.BuildStyle(), "Popup with pos", "Images, round");

            popup1.SetMetaDataElement("ClickText", new Variant("Popup nr 1"));
            source.Add(popup1);
        }
Example #4
0
        public static Marker AddMarkerToPosition(this MapView map, MapPos position)
        {
            // Initialize a local vector data source
            Projection            projection = map.Options.BaseProjection;
            LocalVectorDataSource datasource = new LocalVectorDataSource(projection);

            // Initialize a vector layer with the previous data source
            VectorLayer layer = new VectorLayer(datasource);

            // Add layer to map
            map.Layers.Add(layer);

            // Set marker style
            MarkerStyleBuilder builder = new MarkerStyleBuilder();

            builder.Size  = 20;
            builder.Color = new Carto.Graphics.Color(0, 255, 0, 255);

            MarkerStyle style = builder.BuildStyle();

            // Create marker and add it to the source
            Marker marker = new Marker(position, style);

            datasource.Add(marker);

            return(marker);
        }
Example #5
0
        public static void Add3DPolygon(LocalVectorDataSource source, Projection projection)
        {
            // Create 3d polygon style and poses
            Polygon3DStyleBuilder polygon3DStyleBuilder = new Polygon3DStyleBuilder();

            polygon3DStyleBuilder.Color = new Color(51, 51, 255, 255);

            MapPosVector polygon3DPoses = new MapPosVector();

            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.635930, 59.416659)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.642453, 59.411354)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646187, 59.409607)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.652667, 59.413123)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.650736, 59.416703)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646444, 59.416245)));

            // Create 3d polygon holes poses
            MapPosVector holePositions = new MapPosVector();

            holePositions.Add(projection.FromWgs84(new MapPos(24.643409, 59.411922)));
            holePositions.Add(projection.FromWgs84(new MapPos(24.651207, 59.412896)));
            holePositions.Add(projection.FromWgs84(new MapPos(24.643207, 59.414411)));

            MapPosVectorVector holes = new MapPosVectorVector();

            holes.Add(holePositions);

            // Add to datasource
            Polygon3D polygon = new Polygon3D(polygon3DPoses, holes, polygon3DStyleBuilder.BuildStyle(), 150);

            polygon.SetMetaDataElement("ClickText", new Variant("Polygon 3D"));
            source.Add(polygon);
        }
        public static async void AddMarkerToPosition(this MapView map, MapPos position)
        {
            await ThreadPool.RunAsync(delegate
            {
                // Initialize a local vector data source
                Projection projection = map.Options.BaseProjection;
                LocalVectorDataSource datasource = new LocalVectorDataSource(projection);

                // Initialize a vector layer with the previous data source
                VectorLayer layer = new VectorLayer(datasource);

                // Add layer to map
                map.Layers.Add(layer);

                MarkerStyleBuilder builder = new MarkerStyleBuilder();
                builder.Size = 15;
                builder.Color = new Carto.Graphics.Color(0, 255, 0, 255);
                
                MarkerStyle style = builder.BuildStyle();

                // Create marker and add it to the source
                Marker marker = new Marker(position, style);
                datasource.Add(marker);
            });
        }
Example #7
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Clear the default layer, add a dark one instead
            MapView.Layers.Clear();

            var baseLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDarkmatter);

            // Remove texts so dots would be more prominent
            (baseLayer.TileDecoder as MBVectorTileDecoder).SetStyleParameter("lang", "nolang");

            MapView.Layers.Add(baseLayer);

            Projection projection = MapView.Options.BaseProjection;

            // Create a datasource and layer for the map
            LocalVectorDataSource source = new LocalVectorDataSource(projection);
            VectorLayer           layer  = new VectorLayer(source);

            MapView.Layers.Add(layer);

            // Initialize CartoSQL service, set a username
            CartoSQLService service = new CartoSQLService();

            service.Username = "******";

            PointStyleBuilder builder = new PointStyleBuilder
            {
                Color = new Carto.Graphics.Color(255, 0, 0, 255),
                Size  = 1
            };

            MapView.QueryFeatures(service, source, builder.BuildStyle(), query);
        }
        public static void Add3DPolygon(LocalVectorDataSource source, Projection projection)
        {
            // Create 3d polygon style and poses
            Polygon3DStyleBuilder polygon3DStyleBuilder = new Polygon3DStyleBuilder();
            polygon3DStyleBuilder.Color = new Color(51, 51, 255, 255);

            MapPosVector polygon3DPoses = new MapPosVector();
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.635930, 59.416659)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.642453, 59.411354)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646187, 59.409607)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.652667, 59.413123)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.650736, 59.416703)));
            polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646444, 59.416245)));

            // Create 3d polygon holes poses
            MapPosVector holePositions = new MapPosVector();
            holePositions.Add(projection.FromWgs84(new MapPos(24.643409, 59.411922)));
            holePositions.Add(projection.FromWgs84(new MapPos(24.651207, 59.412896)));
            holePositions.Add(projection.FromWgs84(new MapPos(24.643207, 59.414411)));

            MapPosVectorVector holes = new MapPosVectorVector();
            holes.Add(holePositions);

            // Add to datasource
            Polygon3D polygon = new Polygon3D(polygon3DPoses, holes, polygon3DStyleBuilder.BuildStyle(), 150);
            polygon.SetMetaDataElement("ClickText", new Variant("Polygon 3D"));
            source.Add(polygon);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Initialize source and Edit layer, add it to the map
            source = new LocalVectorDataSource(MapView.Options.BaseProjection);

            editLayer = new EditableVectorLayer(source);
            MapView.Layers.Add(editLayer);

            // Convenience methods to add elements to the map, cf. LocalVectorDataSourceExtensions
            source.AddPoint(new MapPos(-7000000, 7000000));

            source.AddLine(new MapPosVector {
                new MapPos(-9000000, -9000000), new MapPos(-5000000, -500000)
            });

            source.AddPolygon(new MapPosVector {
                new MapPos(-4000000, -4000000), new MapPos(4000000, -4000000), new MapPos(0, 7000000)
            });

            // Add a vector element even listener to select elements (on element click)
            editLayer.VectorElementEventListener = new VectorElementSelectEventListener(editLayer);

            // Add a map even listener to deselect element (on map click)
            MapView.MapEventListener = new VectorElementDeselectEventListener(editLayer);

            // Add the vector element edit even listener
            editLayer.VectorEditEventListener = new BasicEditEventListener(source);
        }
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Initialize source and Edit layer, add it to the map
            source = new LocalVectorDataSource(MapView.Options.BaseProjection);

            editLayer = new EditableVectorLayer(source);
            MapView.Layers.Add(editLayer);

            // Convenience methods to add elements to the map, cf. LocalVectorDataSourceExtensions
            source.AddPoint(new MapPos(-5000000, -900000));

            source.AddLine(new MapPosVector {
                new MapPos(-6000000, -500000), new MapPos(-9000000, -500000)
            });

            source.AddPolygon(new MapPosVector {
                new MapPos(-5000000, -5000000), new MapPos(5000000, -5000000), new MapPos(0, 10000000)
            });

            // Add a vector element event listener to select elements (on element click)
            editLayer.VectorElementEventListener = new VectorElementSelectEventListener(editLayer);

            // Add a map event listener to deselect element (on map click)
            MapView.MapEventListener = new VectorElementDeselectEventListener(editLayer);

            // Add the vector element edit event listener
            editLayer.VectorEditEventListener = new BasicEditEventListener(source);

            Alert("Click on object to modify or move it");
        }
Example #11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Initialize source and Edit layer, add it to the map
            source = new LocalVectorDataSource(MapView.Options.BaseProjection);

            editLayer = new EditableVectorLayer(source);
            MapView.Layers.Add(editLayer);

            // Convenience methods to add elements to the map, cf. LocalVectorDataSourceExtensions
            source.AddPoint(new MapPos(-7000000, 7000000));

            source.AddLine(new MapPosVector {
                new MapPos(-9000000, -9000000), new MapPos(-5000000, -500000)
            });

            source.AddPolygon(new MapPosVector {
                new MapPos(-4000000, -4000000), new MapPos(4000000, -4000000), new MapPos(0, 7000000)
            });

            // Add a vector element even listener to select elements (on element click)
            editLayer.VectorElementEventListener = new VectorElementSelectEventListener(editLayer);

            // Add a map even listener to deselect element (on map click)
            MapView.MapEventListener = new VectorElementDeselectEventListener(editLayer);

            // Add the vector element edit even listener
            editLayer.VectorEditEventListener = new BasicEditEventListener(source);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "mainGPS" layout resource, reload MapView
            SetContentView(Resource.Layout.MainGPS);
            MapView = (MapView)FindViewById(Resource.Id.mapView);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Create layer and add object to the layer, finally add layer to the map.
            // All overlay layers must be same projection as base layer, so we reuse it
            markerSource = new LocalVectorDataSource(MapView.Options.BaseProjection);
            var markerLayer = new VectorLayer(markerSource);

            MapView.Layers.Add(markerLayer);

            if (((int)Build.VERSION.SdkInt) >= Marshmallow)
            {
                // Ask runtime location permission
                RequestLocationPermission();
            }
            else
            {
                // Initialize the location manager to get the current position
                InitializeLocationManager();
            }
        }
Example #13
0
        public override bool OnUTFGridClicked(UTFGridClickInfo clickInfo)
        {
            if (vectorDataSource == null)
            {
                vectorDataSource = (LocalVectorDataSource)vectorLayer.DataSource;
            }

            // Clear previous popups
            vectorDataSource.Clear();

            // Multiple vector elements can be clicked at the same time, we only care about the one
            // Check the type of vector element
            BalloonPopup             clickPopup   = null;
            BalloonPopupStyleBuilder styleBuilder = new BalloonPopupStyleBuilder();

            // Configure style
            styleBuilder.LeftMargins  = new BalloonPopupMargins(0, 0, 0, 0);
            styleBuilder.TitleMargins = new BalloonPopupMargins(6, 3, 6, 3);

            // Make sure this label is shown on top all other labels
            styleBuilder.PlacementPriority = 10;

            // Show clicked element variant as JSON string
            string desc = clickInfo.ElementInfo.ToString();

            clickPopup = new BalloonPopup(clickInfo.ClickPos, styleBuilder.BuildStyle(), "", desc);

            vectorDataSource.Add(clickPopup);

            return(true);
        }
Example #14
0
        void AddPinTo(MapPos position)
        {
            // 1. Initialize a local vector data source
            LocalVectorDataSource vectorDataSource1 = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            VectorLayer vectorLayer1 = new VectorLayer(vectorDataSource1);

            // Add the previous vector layer to the map
            MapView.Layers.Add(vectorLayer1);

            // Set visible zoom range for the vector layer
            vectorLayer1.VisibleZoomRange = new MapRange(0, 18);

            // Create marker style
            Carto.Graphics.Bitmap markerBitmap       = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("marker.png"));
            MarkerStyleBuilder    markerStyleBuilder = new MarkerStyleBuilder();

            markerStyleBuilder.Bitmap = markerBitmap;

            markerStyleBuilder.Size = 30;
            MarkerStyle sharedMarkerStyle = markerStyleBuilder.BuildStyle();

            // 3. Add marker
            MapPos markerPos = MapView.Options.BaseProjection.FromWgs84(position);
            Marker marker1   = new Marker(markerPos, sharedMarkerStyle);

            vectorDataSource1.Add(marker1);

            // Animate map to the marker
            MapView.SetFocusPos(markerPos, 1);
            MapView.SetZoom(12, 1);
        }
Example #15
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "mainGPS" layout resource, reload MapView
            SetContentView(Resource.Layout.MainGPS);
            mapView = (MapView)FindViewById(Resource.Id.mapView);

            // Set online base layer
            var baseLayer = new NutiteqOnlineVectorTileLayer("nutibright-v2a.zip");

            mapView.Layers.Add(baseLayer);

            // bind the textViewMessage
            _textViewMessage = FindViewById <TextView> (Resource.Id.textViewMessage);

            // create layer and add object to the layer, finally add layer to the map.
            // All overlay layers must be same projection as base layer, so we reuse it
            _markerDataSource = new LocalVectorDataSource(mapView.Options.BaseProjection);
            var _markerLayer = new VectorLayer(_markerDataSource);

            mapView.Layers.Add(_markerLayer);

            // inizialize the location manager to get the current position
            InitializeLocationManager();
        }
        public static async void UpdateVisWithGridEvent(this MapView map, string url, Action<string> error = null)
        {
            await ThreadPool.RunAsync(delegate
            {
                map.Layers.Clear();

                // Create overlay layer for Popups
                Projection projection = map.Options.BaseProjection;
                LocalVectorDataSource source = new LocalVectorDataSource(projection);
                VectorLayer layer = new VectorLayer(source);

                // Create VIS loader
                CartoVisLoader loader = new CartoVisLoader();
                loader.DefaultVectorLayerMode = true;
                CartoVisBuilderWithGridEvent builder = new CartoVisBuilderWithGridEvent(map, layer);

                try
                {
                    loader.LoadVis(builder, url);
                }
                catch (Exception e)
                {
                    if (error != null)
                    {
                        error(e.Message);
                    }
                }

                map.Layers.Add(layer);
            });
        }
Example #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (((int)Build.VERSION.SdkInt) >= Marshmallow)
            {
                // Ask runtime location permission
                RequestLocationPermission();
            }
            else
            {
                // Initialize the location manager to get the current position
                InitializeLocationManager();
            }

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleGray);

            markerSource = new LocalVectorDataSource(MapView.Options.BaseProjection);
            var markerLayer = new VectorLayer(markerSource);

            MapView.Layers.Add(markerLayer);

            // Animate map to the content area
            MapPos zhukova = MapView.Options.BaseProjection.FromWgs84(new MapPos(27.5027954, 53.885053)); //longitude, latitude

            MapView.SetFocusPos(zhukova, 1);
            MapView.SetZoom(15, 1);
        }
Example #18
0
        public static void UpdateVisWithGridEvent(this MapView map, string url, Action <string> error = null)
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                map.Layers.Clear();

                // Create overlay layer for Popups
                Projection projection        = map.Options.BaseProjection;
                LocalVectorDataSource source = new LocalVectorDataSource(projection);
                VectorLayer layer            = new VectorLayer(source);

                // Create VIS loader
                CartoVisLoader loader                = new CartoVisLoader();
                loader.DefaultVectorLayerMode        = true;
                CartoVisBuilderWithGridEvent builder = new CartoVisBuilderWithGridEvent(map, layer);

                BinaryData fontData           = AssetUtils.LoadAsset("carto-fonts.zip");
                loader.VectorTileAssetPackage = new ZippedAssetPackage(fontData);

                try
                {
                    loader.LoadVis(builder, url);
                }
                catch (Exception e)
                {
                    if (error != null)
                    {
                        error(e.Message);
                    }
                }

                map.Layers.Add(layer);
            });
        }
        public static async void UpdateVisWithGridEvent(this MapView map, string url, Action <string> error = null)
        {
            await ThreadPool.RunAsync(delegate
            {
                map.Layers.Clear();

                // Create overlay layer for Popups
                Projection projection        = map.Options.BaseProjection;
                LocalVectorDataSource source = new LocalVectorDataSource(projection);
                VectorLayer layer            = new VectorLayer(source);

                // Create VIS loader
                CartoVisLoader loader                = new CartoVisLoader();
                loader.DefaultVectorLayerMode        = true;
                CartoVisBuilderWithGridEvent builder = new CartoVisBuilderWithGridEvent(map, layer);

                try
                {
                    loader.LoadVis(builder, url);
                }
                catch (Exception e)
                {
                    if (error != null)
                    {
                        error(e.Message);
                    }
                }

                map.Layers.Add(layer);
            });
        }
Example #20
0
        public static void AddPoint1(LocalVectorDataSource source, Projection projection)
        {
            Color green  = new Color(0, 255, 0, 255);
            Point point1 = GetPoint(projection, new MapPos(24.651488, 59.423581), green);

            point1.SetMetaDataElement("ClickText", new Variant("Point nr 1"));
            source.Add(point1);
        }
Example #21
0
        public static void AddPoint2(LocalVectorDataSource source, Projection projection)
        {
            Color red    = new Color(255, 0, 0, 255);
            Point point2 = GetPoint(projection, new MapPos(24.655994, 59.422716), red);

            point2.SetMetaDataElement("ClickText", new Variant("Point nr 2"));
            source.Add(point2);
        }
Example #22
0
        public override bool OnVectorTileClicked(VectorTileClickInfo clickInfo)
        {
            LocalVectorDataSource source = (LocalVectorDataSource)layer.DataSource;

            source.Clear();

            Color color = new Color(0, 100, 200, 150);

            Feature  feature  = clickInfo.Feature;
            Geometry geometry = feature.Geometry;

            PointStyleBuilder pointBuilder = new PointStyleBuilder();

            pointBuilder.Color = color;

            LineStyleBuilder lineBuilder = new LineStyleBuilder();

            lineBuilder.Color = color;

            PolygonStyleBuilder polygonBuilder = new PolygonStyleBuilder();

            polygonBuilder.Color = color;

            if (geometry is PointGeometry)
            {
                source.Add(new Point((PointGeometry)geometry, pointBuilder.BuildStyle()));
            }
            else if (geometry is LineGeometry)
            {
                source.Add(new Line((LineGeometry)geometry, lineBuilder.BuildStyle()));
            }
            else if (geometry is PolygonGeometry)
            {
                source.Add(new Polygon((PolygonGeometry)geometry, polygonBuilder.BuildStyle()));
            }
            else if (geometry is MultiGeometry)
            {
                GeometryCollectionStyleBuilder collectionBuilder = new GeometryCollectionStyleBuilder();
                collectionBuilder.PointStyle   = pointBuilder.BuildStyle();
                collectionBuilder.LineStyle    = lineBuilder.BuildStyle();
                collectionBuilder.PolygonStyle = polygonBuilder.BuildStyle();

                source.Add(new GeometryCollection((MultiGeometry)geometry, collectionBuilder.BuildStyle()));
            }

            BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder();

            /// Set a higher placement priority so it would always be visible
            builder.PlacementPriority = 10;

            string message = feature.Properties.ToString();

            BalloonPopup popup = new BalloonPopup(clickInfo.ClickPos, builder.BuildStyle(), "Click", message);

            source.Add(popup);

            return(true);
        }
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStylePositron);

            // read json from assets and add to map
            string json;

            using (System.IO.StreamReader sr = new System.IO.StreamReader(Assets.Open("cities15000.geojson")))
            {
                json = sr.ReadToEnd();
            }

            // Initialize a local vector data source
            LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            ClusteredVectorLayer layer = new ClusteredVectorLayer(source, new MyClusterElementBuilder(this));

            layer.MinimumClusterDistance = 50;

            new System.Threading.Thread((obj) =>
            {
                // Create a basic style, as the ClusterElementBuilder will set the real style
                var markerStyleBuilder  = new MarkerStyleBuilder();
                markerStyleBuilder.Size = 14;
                MarkerStyle style       = markerStyleBuilder.BuildStyle();

                // Read GeoJSON, parse it using SDK GeoJSON parser
                GeoJSONGeometryReader reader = new GeoJSONGeometryReader();

                // Set target projection to base (mercator)
                reader.TargetProjection = BaseProjection;
                Alert("Starting load from .geojson");

                // Read features from local asset
                FeatureCollection features = reader.ReadFeatureCollection(json);
                Alert("Finished load from .geojson");

                VectorElementVector elements = new VectorElementVector();

                for (int i = 0; i < features.FeatureCount; i++)
                {
                    // This data set features point geometry,
                    // however, it can also be LineGeometry or PolygonGeometry
                    PointGeometry geometry = (PointGeometry)features.GetFeature(i).Geometry;
                    elements.Add(new Marker(geometry, style));
                }

                source.AddAll(elements);
                Alert("Clustering started. Please wait...");

                // Add the clustered vector layer to the map
                MapView.Layers.Add(layer);
            }).Start();
        }
        public static void AddPolygon(this LocalVectorDataSource source, MapPosVector positions)
        {
            PolygonStyleBuilder builder = new PolygonStyleBuilder();

            builder.Color = new Color(0, 255, 0, 255);

            Polygon polygon = new Polygon(positions, builder.BuildStyle());

            source.Add(polygon);
        }
        public LocationClient(MapView mapView)
        {
            MapView = mapView;

            source = new LocalVectorDataSource(Projection);
            layer  = new VectorLayer(source);
            MapView.Layers.Add(layer);

            listener = new VectorElementIgnoreListener();
        }
        public BaseGeocodingView()
        {
            var layer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleVoyager);

            MapView.Layers.Add(layer);

            ObjectSource = new LocalVectorDataSource(Projection);
            var objectLayer = new VectorLayer(ObjectSource);

            MapView.Layers.Add(objectLayer);
        }
        public static void AddPoint(this LocalVectorDataSource source, MapPos position)
        {
            PointStyleBuilder builder = new PointStyleBuilder();

            builder.Size  = 30;
            builder.Color = new Color(0, 0, 255, 255);

            Point point = new Point(position, builder.BuildStyle());

            source.Add(point);
        }
        public LocationMarker(MapView map)
        {
            this.map = map;

            projection = map.Options.BaseProjection;
            source     = new LocalVectorDataSource(projection);

            var layer = new VectorLayer(source);

            map.Layers.Add(layer);
        }
        public static void InitializeVectorTileListener(this MapView map, VectorTileLayer layer)
        {
            LocalVectorDataSource source     = new LocalVectorDataSource(map.Options.BaseProjection);
            VectorLayer           popupLayer = new VectorLayer(source);

            map.Layers.Add(popupLayer);

            var listener = new VectorTileListener(popupLayer);

            (layer as VectorTileLayer).VectorTileEventListener = listener;
        }
        public static void AddLine(this LocalVectorDataSource source, MapPosVector positions)
        {
            LineStyleBuilder builder = new LineStyleBuilder();

            builder.Width      = 20;
            builder.ClickWidth = 40;
            builder.Color      = new Color(255, 0, 0, 255);

            Line line = new Line(positions, builder.BuildStyle());

            source.Add(line);
        }
Example #31
0
        public void SetSourcesAndElements(Bitmap olmarker, Bitmap up, Bitmap upleft, Bitmap upright, Color green, Color red, Color white)
        {
            // Define layer and datasource for route line and instructions
            routeDataSource = new LocalVectorDataSource(BaseProjection);
            VectorLayer routeLayer = new VectorLayer(routeDataSource);

            MapView.Layers.Add(routeLayer);

            // Define layer and datasource for route start and stop markers
            routeStartStopDataSource = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            VectorLayer vectorLayer = new VectorLayer(routeStartStopDataSource);

            // Add the previous vector layer to the map
            MapView.Layers.Add(vectorLayer);

            // Set visible zoom range for the vector layer
            vectorLayer.VisibleZoomRange = new MapRange(0, 22);

            // Create markers for start & end and a layer for them
            MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder();

            markerBuilder.Bitmap           = olmarker;
            markerBuilder.HideIfOverlapped = false;
            markerBuilder.Size             = 30;
            markerBuilder.Color            = green;

            startMarker         = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle());
            startMarker.Visible = false;

            markerBuilder.Color = red;

            stopMarker         = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle());
            stopMarker.Visible = false;

            routeStartStopDataSource.Add(startMarker);
            routeStartStopDataSource.Add(stopMarker);

            markerBuilder.Color  = white;
            markerBuilder.Bitmap = up;
            instructionUp        = markerBuilder.BuildStyle();

            markerBuilder.Bitmap = upleft;
            instructionLeft      = markerBuilder.BuildStyle();

            markerBuilder.Bitmap = upright;
            instructionRight     = markerBuilder.BuildStyle();

            // Style for instruction balloons
            balloonBuilder = new BalloonPopupStyleBuilder();
            balloonBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4);
        }
Example #32
0
        public static void AddText2(LocalVectorDataSource source, Projection projection)
        {
            TextStyleBuilder builder = new TextStyleBuilder();

            builder.OrientationMode = BillboardOrientation.BillboardOrientationFaceCamera;

            MapPos position = projection.FromWgs84(new MapPos(24.633216, 59.426869));
            Text   popup    = new Text(position, builder.BuildStyle(), "Face camera ground text");

            popup.SetMetaDataElement("ClickText", new Variant("Text nr 2"));

            source.Add(popup);
        }
Example #33
0
        public static void InitializeVectorTileListener(this VectorTileLayer tileLayer, MapView map)
        {
            LocalVectorDataSource source = new LocalVectorDataSource(map.Options.BaseProjection);
            var vectorLayer = map.FindVectorLayer();

            if (vectorLayer == null)
            {
                vectorLayer = new VectorLayer(source);
                map.Layers.Add(vectorLayer);
            }

            tileLayer.VectorTileEventListener = new VectorTileListener(vectorLayer);
        }
Example #34
0
        public static void Add2DPolygon(LocalVectorDataSource source, Projection projection)
        {
            LineStyleBuilder lineBuilder = new LineStyleBuilder();

            lineBuilder.Color = new Color(0, 0, 0, 255);             // Black
            lineBuilder.Width = 1.0f;

            // Create polygon style and poses
            PolygonStyleBuilder polygonBuilder = new PolygonStyleBuilder();

            polygonBuilder.Color     = new Color(255, 0, 0, 255);         // Red
            polygonBuilder.LineStyle = lineBuilder.BuildStyle();

            MapPosVector polygonPoses = new MapPosVector();

            polygonPoses.Add(projection.FromWgs84(new MapPos(24.650930, 59.421659)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.657453, 59.416354)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.661187, 59.414607)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.667667, 59.418123)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.665736, 59.421703)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.661444, 59.421245)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.660199, 59.420677)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.656552, 59.420175)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.654010, 59.421472)));

            // Create 2 polygon holes
            MapPosVector holePoses1 = new MapPosVector();

            holePoses1.Add(projection.FromWgs84(new MapPos(24.658409, 59.420522)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.662207, 59.418896)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.662207, 59.417411)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.659524, 59.417171)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.657615, 59.419834)));

            MapPosVector holePoses2 = new MapPosVector();

            holePoses2.Add(projection.FromWgs84(new MapPos(24.665640, 59.421243)));
            holePoses2.Add(projection.FromWgs84(new MapPos(24.668923, 59.419463)));
            holePoses2.Add(projection.FromWgs84(new MapPos(24.662893, 59.419365)));

            MapPosVectorVector polygonHoles = new MapPosVectorVector();

            polygonHoles.Add(holePoses1);
            polygonHoles.Add(holePoses2);

            // Add polygon
            Polygon polygon = new Polygon(polygonPoses, polygonHoles, polygonBuilder.BuildStyle());

            polygon.SetMetaDataElement("ClickText", new Variant("Polygon"));
            source.Add(polygon);
        }
Example #35
0
        public static void Add3DCar(LocalVectorDataSource source, Projection projection)
        {
            // Add a single 3D model to the vector layer
            // Be sure to add milktruck.nml to your *Assets*, not Drawable, folder (Android)
            string name = "milktruck.nml";

            MapPos   modelPos = projection.FromWgs84(new MapPos(24.646469, 59.423939));
            NMLModel model    = new NMLModel(modelPos, AssetUtils.LoadAsset(name));

            model.Scale = 20;
            model.SetMetaDataElement("ClickText", new Variant("Single model"));

            source.Add(model);
        }
Example #36
0
        public static void Add3DCar(LocalVectorDataSource source, Projection projection)
        {
            // Add a single 3D model to the vector layer
            // Be sure to add milktruck.nml to your *Assets*, not Drawable, folder (Android)
            string name = "milktruck.nml";

            MapPos modelPos = projection.FromWgs84(new MapPos(24.646469, 59.423939));
            NMLModel model = new NMLModel(modelPos, AssetUtils.LoadAsset(name));

            model.Scale = 20;
            model.SetMetaDataElement("ClickText", new Variant("Single model"));

            source.Add(model);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Add default base layer
            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            LocationManager = new LocationManager();
            LocationManager.Start();

            // Create layer and add object to the layer, finally add layer to the map.
            // All overlay layers must be same projection as base layer, so we reuse it
            markerSource = new LocalVectorDataSource(MapView.Options.BaseProjection);
            var _markerLayer = new VectorLayer(markerSource);
            MapView.Layers.Add(_markerLayer);
        }
        public static void QueryFeatures(this MapView map, CartoSQLService service, LocalVectorDataSource source, PointStyle style, string query)
        {
            System.Threading.Tasks.Task.Run(delegate
            {
                FeatureCollection features = service.QueryFeatures(query, map.Options.BaseProjection);

                for (int i = 0; i < features.FeatureCount; i++)
                {
                    Feature feature = features.GetFeature(i);

                    PointGeometry geometry = (PointGeometry)feature.Geometry;

                    var point = new Point(geometry, style);
                    source.Add(point);
                }

            });
        }
Example #39
0
        public static void Add2DPolygon(LocalVectorDataSource source, Projection projection)
        {
            LineStyleBuilder lineBuilder = new LineStyleBuilder();
            lineBuilder.Color = new Color(0, 0, 0, 255); // Black
            lineBuilder.Width = 1.0f;

            // Create polygon style and poses
            PolygonStyleBuilder polygonBuilder = new PolygonStyleBuilder();
            polygonBuilder.Color = new Color(255, 0, 0, 255); // Red
            polygonBuilder.LineStyle = lineBuilder.BuildStyle();

            MapPosVector polygonPoses = new MapPosVector();
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.650930, 59.421659)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.657453, 59.416354)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.661187, 59.414607)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.667667, 59.418123)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.665736, 59.421703)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.661444, 59.421245)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.660199, 59.420677)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.656552, 59.420175)));
            polygonPoses.Add(projection.FromWgs84(new MapPos(24.654010, 59.421472)));

            // Create 2 polygon holes
            MapPosVector holePoses1 = new MapPosVector();
            holePoses1.Add(projection.FromWgs84(new MapPos(24.658409, 59.420522)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.662207, 59.418896)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.662207, 59.417411)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.659524, 59.417171)));
            holePoses1.Add(projection.FromWgs84(new MapPos(24.657615, 59.419834)));

            MapPosVector holePoses2 = new MapPosVector();
            holePoses2.Add(projection.FromWgs84(new MapPos(24.665640, 59.421243)));
            holePoses2.Add(projection.FromWgs84(new MapPos(24.668923, 59.419463)));
            holePoses2.Add(projection.FromWgs84(new MapPos(24.662893, 59.419365)));

            MapPosVectorVector polygonHoles = new MapPosVectorVector();
            polygonHoles.Add(holePoses1);
            polygonHoles.Add(holePoses2);

            // Add polygon
            Polygon polygon = new Polygon(polygonPoses, polygonHoles, polygonBuilder.BuildStyle());
            polygon.SetMetaDataElement("ClickText", new Variant("Polygon"));
            source.Add(polygon);
        }
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Initialize a local vector data source
            LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            VectorLayer layer = new VectorLayer(source);

            // Add the previous vector layer to the map
            MapView.Layers.Add(layer);
            // Set visible zoom range for the vector layer
            layer.VisibleZoomRange = new MapRange(0, 18);

            // Create marker style
            Android.Graphics.Bitmap image = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.marker);
            Carto.Graphics.Bitmap markerBitmap = BitmapUtils.CreateBitmapFromAndroidBitmap(image);

            MarkerStyleBuilder builder = new MarkerStyleBuilder();
            builder.Bitmap = markerBitmap;
            builder.Size = 30;
            MarkerStyle style = builder.BuildStyle();

            // Add marker
            MapPos washington = BaseProjection.FromWgs84(new MapPos(-77.0369, 38.9072));
            Marker marker = new Marker(washington, style);
            source.Add(marker);

            // Animate map to the marker
            MapView.SetFocusPos(washington, 1);
            MapView.SetZoom(8, 1);

            listener = new RenderListener();
            MapView.MapRenderer.CaptureRendering(listener, true);
        }
 public VectorElementListener(LocalVectorDataSource dataSource)
 {
     source = dataSource;
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "mainGPS" layout resource, reload MapView
            SetContentView(Resource.Layout.MainGPS);
            MapView = (MapView)FindViewById(Resource.Id.mapView);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Create layer and add object to the layer, finally add layer to the map.
            // All overlay layers must be same projection as base layer, so we reuse it
            markerSource = new LocalVectorDataSource(MapView.Options.BaseProjection);
            var markerLayer = new VectorLayer(markerSource);

            MapView.Layers.Add(markerLayer);

            if (((int)Build.VERSION.SdkInt) >= Marshmallow)
            {
                // Ask runtime location permission
                RequestLocationPermission();
            }
            else {
                // Initialize the location manager to get the current position
                InitializeLocationManager();
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleGray);

            Projection projection = BaseProjection;

            // Initialize an local vector data source
            LocalVectorDataSource source = new LocalVectorDataSource(projection);

            // Initialize a vector layer with the previous data source
            VectorLayer vectorLayer = new VectorLayer(source);

            // Add the previous vector layer to the map
            MapView.Layers.Add(vectorLayer);

            // Set visible zoom range for the vector layer
            vectorLayer.VisibleZoomRange = new MapRange(10, 24);

            // Add a bunch of vector elements
            // As elements can be shared across platforms, they are in a shared project

            Overlays.AddPoint1(source, projection);
            Overlays.AddPoint2(source, projection);

            Overlays.AddOverlyingLines(MapView, source, projection);

            Overlays.Add2DPolygon(source, projection);

            Overlays.AddText1(source, projection);
            Overlays.AddText2(source, projection);
            Overlays.AddText3(source, projection);

            Bitmap info = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("icons/info.png"));
            Bitmap arrow = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("icons/arrow.png"));
            Bitmap marker = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("icons/marker.png"));

            Overlays.AddBalloonPopup1(source, projection, info, arrow);
            Overlays.AddBalloonPopup2(source, projection, info, arrow, marker);
            Overlays.AddBalloonPopup3(source, projection);

            Overlays.Add3DCar(source, projection);
            Overlays.Add3DPolygon(source, projection);

            // Animate map to Tallinn where the objects are
            MapView.SetFocusPos(projection.FromWgs84(new MapPos(24.662893, 59.419365)), 1);
            MapView.SetZoom(12, 1);

            // Add maplistener to detect click on model

            listener = new VectorElementListener(source);
            for (int i = 0; i < MapView.Layers.Count; i++)
            {
                Layer layer = MapView.Layers[i];

                if (layer is VectorLayer)
                {
                    (layer as VectorLayer).VectorElementEventListener = listener;
                }
            }
        }
        public override bool OnUTFGridClicked(UTFGridClickInfo clickInfo)
        {
            if (vectorDataSource == null)
            {
                vectorDataSource = (LocalVectorDataSource)vectorLayer.DataSource;
            }

            // Clear previous popups
            vectorDataSource.Clear();

            // Multiple vector elements can be clicked at the same time, we only care about the one
            // Check the type of vector element
            BalloonPopup clickPopup = null;
            BalloonPopupStyleBuilder styleBuilder = new BalloonPopupStyleBuilder();

            // Configure style
            styleBuilder.LeftMargins = new BalloonPopupMargins(0, 0, 0, 0);
            styleBuilder.TitleMargins = new BalloonPopupMargins(6, 3, 6, 3);

            // Make sure this label is shown on top all other labels
            styleBuilder.PlacementPriority = 10;

            // Show clicked element variant as JSON string
            string desc = clickInfo.ElementInfo.ToString();

            clickPopup = new BalloonPopup(clickInfo.ClickPos, styleBuilder.BuildStyle(), "Clicked", desc);

            vectorDataSource.Add(clickPopup);

            return true;
        }
 public MyUTFGridEventListener(LocalVectorDataSource source)
 {
     vectorDataSource = source;
 }
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Initialize a local vector data source
            LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            VectorLayer layer = new VectorLayer(source);

            // Add the previous vector layer to the map
            MapView.Layers.Add(layer);

            // Create marker style
            Android.Graphics.Bitmap androidMarkerBitmap = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.marker);
            Carto.Graphics.Bitmap markerBitmap = Carto.Utils.BitmapUtils.CreateBitmapFromAndroidBitmap(androidMarkerBitmap);

            MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();
            markerStyleBuilder.Bitmap = markerBitmap;
            markerStyleBuilder.Size = 30;
            MarkerStyle markerStyle = markerStyleBuilder.BuildStyle();

            // Add marker
            MapPos berlin = MapView.Options.BaseProjection.FromWgs84(new MapPos(13.38933, 52.51704));
            Marker marker = new Marker(berlin, markerStyle);
            source.Add(marker);

            // Add popup
            PopupStyleBuilder builder = new PopupStyleBuilder();
            builder.SetAttachAnchorPoint(0.5f, 0);
            PopupStyle popupStyle = builder.BuildStyle();

            BasicCustomPopupHandler popupHandler = new BasicCustomPopupHandler("custom popup");

            CustomPopup popup = new CustomPopup(marker, popupStyle, popupHandler);
            popup.SetAnchorPoint(-1, 0);
            source.Add(popup);

            // Animate map to the marker
            MapView.SetFocusPos(berlin, 1);
            MapView.SetZoom(12, 1);
        }
Example #47
0
        public void CreateRoutePoint(MapPos pos, RoutingInstruction instruction, LocalVectorDataSource source)
        {
            MarkerStyle style = instructionUp;
            string str = "";

            switch (instruction.Action)
            {
                case RoutingAction.RoutingActionHeadOn:
                    str = "head on";
                    break;
                case RoutingAction.RoutingActionFinish:
                    str = "finish";
                    break;
                case RoutingAction.RoutingActionTurnLeft:
                    style = instructionLeft;
                    str = "turn left";
                    break;
                case RoutingAction.RoutingActionTurnRight:
                    style = instructionRight;
                    str = "turn right";
                    break;
                case RoutingAction.RoutingActionUturn:
                    str = "u turn";
                    break;
                case RoutingAction.RoutingActionNoTurn:
                case RoutingAction.RoutingActionGoStraight:
                    //style = instructionUp;
                    //str = "continue";
                    break;
                case RoutingAction.RoutingActionReachViaLocation:
                    style = instructionUp;
                    str = "stopover";
                    break;
                case RoutingAction.RoutingActionEnterAgainstAllowedDirection:
                    str = "enter against allowed direction";
                    break;
                case RoutingAction.RoutingActionLeaveAgainstAllowedDirection:
                    break;
                case RoutingAction.RoutingActionEnterRoundabout:
                    str = "enter roundabout";
                    break;
                case RoutingAction.RoutingActionStayOnRoundabout:
                    str = "stay on roundabout";
                    break;
                case RoutingAction.RoutingActionLeaveRoundabout:
                    str = "leave roundabout";
                    break;
                case RoutingAction.RoutingActionStartAtEndOfStreet:
                    str = "start at end of street";
                    break;
            }

            if (str != "")
            {
                Marker marker = new Marker(pos, style);
                BalloonPopup popup2 = new BalloonPopup(marker, balloonBuilder.BuildStyle(), str, "");

                source.Add(popup2);
                source.Add(marker);
            }
        }
Example #48
0
        public static void AddOverlyingLines(MapView map, LocalVectorDataSource source, Projection projection)
        {
            // Initialize a second vector data source and vector layer
            // This secondary vector layer will be used for drawing borders for
            // line elements (by drawing the same line twice, with different widths)
            // Drawing order withing a layer is currently undefined
            // Using multiple layers is the only way to guarantee
            // that point, line and polygon elements are drawn in a specific order
            LocalVectorDataSource source2 = new LocalVectorDataSource(projection);
            VectorLayer vectorLayer2 = new VectorLayer(source2);
            map.Layers.Add(vectorLayer2);

            vectorLayer2.VisibleZoomRange = new MapRange(10, 24);

            // Create line style, and line poses
            LineStyleBuilder lineStyleBuilder = new LineStyleBuilder();
            lineStyleBuilder.Color = new Color(255, 255, 255, 255); // White
            lineStyleBuilder.Width = 8;

            MapPosVector linePoses = new MapPosVector();

            linePoses.Add(projection.FromWgs84(new MapPos(24.645565, 59.422074)));
            linePoses.Add(projection.FromWgs84(new MapPos(24.643076, 59.420502)));
            linePoses.Add(projection.FromWgs84(new MapPos(24.645351, 59.419149)));
            linePoses.Add(projection.FromWgs84(new MapPos(24.648956, 59.420393)));
            linePoses.Add(projection.FromWgs84(new MapPos(24.650887, 59.422707)));

            // Add first line
            Line line1 = new Line(linePoses, lineStyleBuilder.BuildStyle());
            line1.SetMetaDataElement("ClickText", new Variant("Line nr 1"));
            source2.Add(line1);

            // Create another line style, use the same lines poses
            lineStyleBuilder = new LineStyleBuilder();
            lineStyleBuilder.Color = new Color(204, 15, 0, 255);
            lineStyleBuilder.Width = 12;

            // Add second line to the second layer.
            Line line2 = new Line(linePoses, lineStyleBuilder.BuildStyle());
            line2.SetMetaDataElement("ClickText", new Variant("Line nr 2"));
            source.Add(line2);
        }
 public MyMapEventListener(MapView mapView, LocalVectorDataSource vectorDataSource)
 {
     this.mapView = mapView;
     this.vectorDataSource = vectorDataSource;
 }
Example #50
0
        public static void AddBalloonPopup3(LocalVectorDataSource source, Projection projection)
        {
            // Add popup
            BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder();
            builder.DescriptionWrap = false;
            builder.PlacementPriority = 1;
            builder.TitleFontSize = 14;
            builder.DescriptionFontSize = 12;

            MapPos position = projection.FromWgs84(new MapPos(24.658662, 59.432521));
            String title = "This title will be wrapped if there's not enough space on the screen.";
            String description = "Description is set to be truncated with three dots, unless the screen is really really big.";

            BalloonPopup popup = new BalloonPopup(position, builder.BuildStyle(), title, description);

            popup.SetMetaDataElement("ClickText", new Variant("Popup nr 3"));

            source.Add(popup);
        }
Example #51
0
 public static void AddPoint2(LocalVectorDataSource source, Projection projection)
 {
     Color red = new Color(255, 0, 0, 255);
     Point point2 = GetPoint(projection, new MapPos(24.655994, 59.422716), red);
     point2.SetMetaDataElement("ClickText", new Variant("Point nr 2"));
     source.Add(point2);
 }
Example #52
0
        public void SetSourcesAndElements(Bitmap olmarker, Bitmap up, Bitmap upleft, Bitmap upright, Color green, Color red, Color white)
        {
            // Define layer and datasource for route line and instructions
            routeDataSource = new LocalVectorDataSource(BaseProjection);
            VectorLayer routeLayer = new VectorLayer(routeDataSource);
            MapView.Layers.Add(routeLayer);

            // Define layer and datasource for route start and stop markers
            routeStartStopDataSource = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            VectorLayer vectorLayer = new VectorLayer(routeStartStopDataSource);

            // Add the previous vector layer to the map
            MapView.Layers.Add(vectorLayer);

            // Set visible zoom range for the vector layer
            vectorLayer.VisibleZoomRange = new MapRange(0, 22);

            // Create markers for start & end and a layer for them
            MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder();
            markerBuilder.Bitmap = olmarker;
            markerBuilder.HideIfOverlapped = false;
            markerBuilder.Size = 30;
            markerBuilder.Color = green;

            startMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle());
            startMarker.Visible = false;

            markerBuilder.Color = red;

            stopMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle());
            stopMarker.Visible = false;

            routeStartStopDataSource.Add(startMarker);
            routeStartStopDataSource.Add(stopMarker);

            markerBuilder.Color = white;
            markerBuilder.Bitmap = up;
            instructionUp = markerBuilder.BuildStyle();

            markerBuilder.Bitmap = upleft;
            instructionLeft = markerBuilder.BuildStyle();

            markerBuilder.Bitmap = upright;
            instructionRight = markerBuilder.BuildStyle();

            // Style for instruction balloons
            balloonBuilder = new BalloonPopupStyleBuilder();
            balloonBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4);
        }
Example #53
0
 public static void AddPoint1(LocalVectorDataSource source, Projection projection)
 {
     Color green = new Color(0, 255, 0, 255);
     Point point1 = GetPoint(projection, new MapPos(24.651488, 59.423581), green);
     point1.SetMetaDataElement("ClickText", new Variant("Point nr 1"));
     source.Add(point1);
 }
Example #54
0
        public static void AddText3(LocalVectorDataSource source, Projection projection)
        {
            TextStyleBuilder builder = new TextStyleBuilder();
            builder.FontSize = 22;
            builder.OrientationMode = BillboardOrientation.BillboardOrientationGround;

            MapPos position = projection.FromWgs84(new MapPos(24.646457, 59.420839));
            Text popup = new Text(position, builder.BuildStyle(), "Ground text");
            popup.SetMetaDataElement("ClickText", new Variant("Text nr 3"));

            source.Add(popup);
        }
Example #55
0
        public static void AddText1(LocalVectorDataSource source, Projection projection)
        {
            // Create text style
            TextStyleBuilder builder = new TextStyleBuilder();
            builder.Color = new Color(255, 0, 0, 255); // Red
            builder.OrientationMode = BillboardOrientation.BillboardOrientationFaceCamera;

            // This enables higher resolution texts for retina devices, but consumes more memory and is slower
            builder.ScaleWithDPI = false;

            // Add text
            MapPos position = projection.FromWgs84(new MapPos(24.653302, 59.422269));
            Text popup = new Text(position, builder.BuildStyle(), "Face camera text");

            popup.SetMetaDataElement("ClickText", new Variant("Text nr 1"));
            source.Add(popup);
        }
 public MapListener(LocalVectorDataSource dataSource)
 {
     _dataSource = dataSource;
 }
Example #57
0
        public static void AddBalloonPopup2(LocalVectorDataSource source, Projection projection, 
		                                    Bitmap leftImage, Bitmap rightImage, Bitmap markerImage)
        {
            // Add popup, but instead of giving it a position attach it to a marker
            BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder();
            builder.Color = new Color(0, 0, 0, 255);
            builder.CornerRadius = 0;

            builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6);
            builder.LeftImage = leftImage;

            builder.RightImage = rightImage;
            builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6);

            builder.TitleColor = new Color(255, 255, 255, 255);
            builder.TitleFontName = "HelveticaNeue-Medium";
            builder.TitleFontSize = 11;
            builder.DescriptionColor = new Color(255, 255, 255, 255);
            builder.DescriptionFontName = "HelveticaNeue-Medium";
            builder.DescriptionFontSize = 11;

            builder.StrokeColor = new Color(255, 0, 120, 255);
            builder.StrokeWidth = 0;

            builder.PlacementPriority = 1;

            Marker marker = GetMarker(projection, new MapPos(24.646469, 59.426939), markerImage);
            source.Add(marker);

            Marker marker2 = GetMarker(projection, new MapPos(24.666469, 59.422939), markerImage);
            source.Add(marker2);

            BalloonPopup popup = new BalloonPopup(marker, builder.BuildStyle(), "Popup attached to marker", "Black, rectangle.");
            popup.SetMetaDataElement("ClickText", new Variant("Popup nr 2"));

            source.Add(popup);
        }
Example #58
0
        public static void AddBalloonPopup1(LocalVectorDataSource source, Projection projection, Bitmap leftImage, Bitmap rightImage)
        {
            // TODO REMOVE WHEN ANDROID COMPLETE
            //Bitmap infoImage = BitmapFactory.decodeResource(getResources(), R.drawable.info);
            //Bitmap arrowImage = BitmapFactory.decodeResource(getResources(), R.drawable.arrow);

            //BitmapUtils.createBitmapFromAndroidBitmap(infoImage)
            //BitmapUtils.createBitmapFromAndroidBitmap(arrowImage);

            // Add popup
            BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder();

            builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6);
            builder.LeftImage = leftImage;

            builder.RightImage = rightImage;
            builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6);

            builder.CornerRadius = 20;
            builder.PlacementPriority = 1;
            builder.TitleFontSize = 10;
            builder.DescriptionFontSize = 10;

            MapPos position = projection.FromWgs84(new MapPos(24.655662, 59.425521));
            BalloonPopup popup1 = new BalloonPopup(position, builder.BuildStyle(), "Popup with pos", "Images, round");

            popup1.SetMetaDataElement("ClickText", new Variant("Popup nr 1"));
            source.Add(popup1);
        }
Example #59
0
        public static void AddText2(LocalVectorDataSource source, Projection projection)
        {
            TextStyleBuilder builder = new TextStyleBuilder();
            builder.OrientationMode = BillboardOrientation.BillboardOrientationFaceCamera;

            MapPos position = projection.FromWgs84(new MapPos(24.633216, 59.426869));
            Text popup = new Text(position, builder.BuildStyle(), "Face camera ground text");
            popup.SetMetaDataElement("ClickText", new Variant("Text nr 2"));

            source.Add(popup);
        }