Example #1
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 #2
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
            routeDataSource = new LocalVectorDataSource(Projection);
            routeLayer      = new VectorLayer(routeDataSource);
            MapView.Layers.Add(routeLayer);

            // Define layer and datasource for route instructions
            routeInstructionSource = new LocalVectorDataSource(Projection);
            routeInstructionLayer  = new VectorLayer(routeInstructionSource);
            MapView.Layers.Add(routeInstructionLayer);

            // Define layer and datasource for route start and stop markers
            routeStartStopDataSource = new LocalVectorDataSource(Projection);
            // Initialize a vector layer with the previous data source
            startStopLayer = new VectorLayer(routeStartStopDataSource);
            // Add the previous vector layer to the map
            MapView.Layers.Add(startStopLayer);

            // 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;
            markerBuilder.Size   = 20;
            instructionUp        = markerBuilder.BuildStyle();

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

            markerBuilder.Bitmap = upright;
            instructionRight     = markerBuilder.BuildStyle();
        }
Example #3
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);
        }
        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 #5
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 #6
0
        void AddMarker(string currentPositionTitle, string currentPositionSubtitle, float latitude, float longitude)
        {
            // Define the location of the marker, it must be converted to base map coordinate system
            MapPos currentLocation = mapView.Options.BaseProjection.FromWgs84(new MapPos(longitude, latitude));

            // load default market style
            MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();

            // add the label to the Marker
            _currentPositionMarker = new Marker(currentLocation, markerStyleBuilder.BuildStyle());

            // Define label what is shown when you click on marker, with default style
            var balloonPopupStyleBuilder = new BalloonPopupStyleBuilder();

            _currentPositionMarkerLabel = new BalloonPopup(_currentPositionMarker, balloonPopupStyleBuilder.BuildStyle(), currentPositionTitle, currentPositionSubtitle);

            // add the marker and label to the layer
            _markerDataSource.Add(_currentPositionMarker);
            _markerDataSource.Add(_currentPositionMarkerLabel);

            //center the map in the current location
            mapView.FocusPos = currentLocation;

            //zoom in the map in the current location
            mapView.Zoom = 19f;
        }
        void AddMarker(string title, string subtitle, float latitude, float longitude)
        {
            // Define the location of the marker, it must be converted to base map coordinate system
            MapPos location = MapView.Options.BaseProjection.FromWgs84(new MapPos(longitude, latitude));

            // Load default market style
            MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder();

            // Add the label to the Marker
            positionMarker = new Marker(location, markerBuilder.BuildStyle());

            // Define label what is shown when you click on marker, with default style
            var balloonBuilder = new BalloonPopupStyleBuilder();

            positionLabel = new BalloonPopup(positionMarker, balloonBuilder.BuildStyle(), title, subtitle);

            // Add the marker and label to the layer
            markerSource.Add(positionMarker);
            markerSource.Add(positionLabel);

            // Center the map in the current location
            MapView.FocusPos = location;

            // Zoom in the map in the current location
            MapView.Zoom = 19f;
        }
 public override void OnMapClicked(MapClickInfo mapClickInfo)
 {
     // Add default marker to the click location
     var styleBuilder = new MarkerStyleBuilder ();
     styleBuilder.Size = 10;
     var marker = new Marker (mapClickInfo.ClickPos, styleBuilder.BuildStyle());
     _dataSource.Add (marker);
 }
        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 override void OnMapClicked(MapClickInfo mapClickInfo)
        {
            // Add default marker to the click location
            var styleBuilder = new MarkerStyleBuilder();

            styleBuilder.Size = 10;
            var marker = new Marker(mapClickInfo.ClickPos, styleBuilder.BuildStyle());

            _dataSource.Add(marker);
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

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

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

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

            // Default is 100. A good value depends on data
            layer.MinimumClusterDistance = 50;

            // read json from assets and add to map
            string json = System.IO.File.ReadAllText(AssetUtils.CalculateResourcePath("cities15000.geojson"));

            // 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;

            // Read features from local asset
            FeatureCollection features = reader.ReadFeatureCollection(json);

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

            // Add the clustered vector layer to the map
            source.AddAll(elements);

            MapView.Layers.Add(layer);
        }
Example #12
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddBaseLayer(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);
        }
        public override void OnMapClicked(MapClickInfo mapClickInfo)
        {
            base.OnMapClicked(mapClickInfo);

            MarkerStyleBuilder builder = new MarkerStyleBuilder();

            // Set random size (within reasonable limits)
            int size = GetRandomInt(15, 50);
            builder.Size = size;

            // Set random color from our list
            builder.Color = colors[GetRandomInt(0, colors.Length)];

            // Set a new style to the marker
            marker.Style = builder.BuildStyle();
        }
        public void AddUserMarker(MapPos position)
        {
            var builder = new MarkerStyleBuilder();

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

            var animationBuilder = new AnimationStyleBuilder();

            animationBuilder.SizeAnimationType = AnimationType.AnimationTypeSpring;
            builder.AnimationStyle             = animationBuilder.BuildStyle();

            MarkerSource.Add(new Marker(position, builder.BuildStyle()));
        }
        public override VectorElement BuildClusterElement(MapPos pos, VectorElementVector elements)
        {
            // Try to reuse existing marker styles
            MarkerStyle style = null;

            style = FindByKey(elements.Count);

            if (elements.Count == 1)
            {
                style = ((Marker)elements[0]).Style;
            }

            if (style == null)
            {
                UIFont font = UIFont.FromName("Helvetica Neue", 10);
                UIGraphics.BeginImageContext(markerImage.Size);

                // Draw existing image on new image context;
                markerImage.Draw(new CGPoint(0, 0));

                NSString native = new NSString(elements.Count.ToString());

                // Find the center location and draw text there
                nfloat y         = markerImage.Size.Height / 4;
                CGRect rectangle = new CGRect(0, y, markerImage.Size.Width, markerImage.Size.Height);
                native.DrawString(rectangle, font, UILineBreakMode.WordWrap, UITextAlignment.Center);

                // Extract image
                UIImage newImage = UIGraphics.GetImageFromCurrentImageContext();

                UIGraphics.EndImageContext();

                MarkerStyleBuilder styleBuilder = new MarkerStyleBuilder();
                styleBuilder.Bitmap            = BitmapUtils.CreateBitmapFromUIImage(newImage);
                styleBuilder.Size              = 30;
                styleBuilder.PlacementPriority = elements.Count;

                style = styleBuilder.BuildStyle();

                markerStyles.Add(elements.Count, style);
            }

            // Create marker for the cluster
            Marker marker = new Marker(pos, style);

            return(marker);
        }
Example #16
0
        static Marker GetMarker(Projection projection, MapPos position, Bitmap image)
        {
            //TODO
            //Bitmap androidMarkerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
            //com.carto.graphics.Bitmap markerBitmap = BitmapUtils.createBitmapFromAndroidBitmap(androidMarkerBitmap);

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

            builder.Bitmap = image;
            builder.Size   = 30;

            MarkerStyle style = builder.BuildStyle();

            // Create and return marker
            return(new Marker(projection.FromWgs84(position), style));
        }
        public override VectorElement BuildClusterElement(MapPos pos, VectorElementVector elements)
        {
            MarkerStyle style = null;

            // Try to reuse existing marker styles
            if (markerStyles.ContainsKey(elements.Count))
            {
                style = markerStyles[elements.Count];
            }

            if (elements.Count == 1)
            {
                style = (elements[0] as Marker).Style;
            }

            if (style == null)
            {
                Android.Graphics.Bitmap canvasBitmap = markerBitmap.Copy(Android.Graphics.Bitmap.Config.Argb8888, true);
                Android.Graphics.Canvas canvas       = new Android.Graphics.Canvas(canvasBitmap);

                Android.Graphics.Paint paint = new Android.Graphics.Paint(Android.Graphics.PaintFlags.AntiAlias);

                paint.TextAlign = (Android.Graphics.Paint.Align.Center);
                paint.TextSize  = 12;
                paint.Color     = Android.Graphics.Color.Argb(255, 0, 0, 0);

                float x = markerBitmap.Width / 2;
                float y = markerBitmap.Height / 2 - 5;

                canvas.DrawText(elements.Count.ToString(), x, y, paint);

                MarkerStyleBuilder styleBuilder = new MarkerStyleBuilder();
                styleBuilder.Bitmap            = BitmapUtils.CreateBitmapFromAndroidBitmap(canvasBitmap);
                styleBuilder.Size              = 30;
                styleBuilder.PlacementPriority = -elements.Count;

                style = styleBuilder.BuildStyle();

                markerStyles.Add(elements.Count, style);
            }

            // Create marker for the cluster
            Marker marker = new Marker(pos, style);

            return(marker);
        }
        public override void OnMapClicked(MapClickInfo mapClickInfo)
        {
            base.OnMapClicked(mapClickInfo);

            MarkerStyleBuilder builder = new MarkerStyleBuilder();

            // Set random size (within reasonable limits)
            int size = GetRandomInt(15, 50);

            builder.Size = size;

            // Set random color from our list
            builder.Color = colors[GetRandomInt(0, colors.Length)];

            // Set a new style to the marker
            marker.Style = builder.BuildStyle();
        }
        public override bool OnVectorElementClicked(VectorElementClickInfo clickInfo)
        {
            // A note about iOS: DISABLE 'Optimize PNG files for iOS' option in iOS build settings,
            // otherwise icons can not be loaded using AssetUtils/Bitmap constructor as Xamarin converts
            // PNGs to unsupported custom format.
            var bitmap = BitmapUtils.LoadBitmapFromAssets("Icon.png");

            var styleBuilder = new MarkerStyleBuilder();

            styleBuilder.Size   = 20;
            styleBuilder.Bitmap = bitmap;
            styleBuilder.Color  = new Carto.Graphics.Color(200, 0, 200, 200);
            var marker = new Marker(clickInfo.ClickPos, styleBuilder.BuildStyle());

            _dataSource.Add(marker);

            return(true);
        }
        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  = 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);


                // Add text element to same location
                TextStyleBuilder MyStyleBuilder = new TextStyleBuilder
                {
                    OrientationMode  = BillboardOrientation.BillboardOrientationGround,
                    FontSize         = 12.0f,
                    CausesOverlap    = false,
                    Color            = new Carto.Graphics.Color(255, 0, 0, 255),
                    ScalingMode      = BillboardScaling.BillboardScalingWorldSize,
                    Flippable        = false,
                    HideIfOverlapped = false,
                    RenderScale      = 8.0f
                };

                Text text = new Text(position, MyStyleBuilder.BuildStyle(), "TEXT");

                datasource.Add(marker);
                datasource.Add(text);
            });
        }
Example #21
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Add a pin marker to map
            // 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
            Bitmap androidMarkerBitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.marker);

            Carto.Graphics.Bitmap markerBitmap = BitmapUtils.CreateBitmapFromAndroidBitmap(androidMarkerBitmap);

            MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();

            markerStyleBuilder.Bitmap = markerBitmap;

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

            // 3. Add marker
            //MapPos berlin = new MapPos(13.38933, 52.51704);
            MapPos tallinn = new MapPos(24.646469, 59.426939);

            MapPos markerPos = MapView.Options.BaseProjection.FromWgs84(tallinn);
            Marker marker1   = new Marker(markerPos, sharedMarkerStyle);

            vectorDataSource1.Add(marker1);

            // Animate map to the marker
            MapView.SetFocusPos(markerPos, 1);
            MapView.SetZoom(12, 1);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Add default base layer
            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
            UIImage image        = UIImage.FromFile("icons/marker.png");
            Bitmap  markerBitmap = BitmapUtils.CreateBitmapFromUIImage(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(12, 1);

            listener = new RenderListener(this, MapView);
            MapView.MapRenderer.CaptureRendering(listener, true);
        }
Example #23
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddBaseLayer(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 berlin = BaseProjection.FromWgs84(new MapPos(13.38933, 52.51704));
            Marker marker = new Marker(berlin, style);

            source.Add(marker);

            // Animate map to the marker
            MapView.SetFocusPos(berlin, 1);
            MapView.SetZoom(12, 1);

            listener = new RenderListener(this, MapView);
            MapView.MapRenderer.CaptureRendering(listener, true);
        }
Example #24
0
        void OnLocationUpdate(object sender, LocationUpdatedEventArgs e)
        {
            double latitude  = e.Location.Coordinate.Latitude;
            double longitude = e.Location.Coordinate.Longitude;

            string title       = "Your current location";
            string description = latitude.To4Decimals() + ", " + longitude.To4Decimals();

            MapPos location = MapView.Options.BaseProjection.FromWgs84(new MapPos(longitude, latitude));

            if (IsMarkerSet)
            {
                markerLabel.Description = description;
                positionMarker.Geometry = new PointGeometry(location);
                return;
            }

            // Load default market style
            MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();

            // Add the label to the Marker
            positionMarker = new Marker(location, markerStyleBuilder.BuildStyle());

            // Define label what is shown when you click on marker, with default style
            var builder = new BalloonPopupStyleBuilder();

            markerLabel = new BalloonPopup(positionMarker, builder.BuildStyle(), title, description);

            // Add the marker and label to the layer
            markerSource.Add(positionMarker);
            markerSource.Add(markerLabel);

            // Center the map in the current location
            MapView.FocusPos = location;

            // Zoom in the map in the current location
            MapView.Zoom = 19f;
        }
        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 override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

            LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection);
            VectorLayer           layer  = new VectorLayer(source);

            MapView.Layers.Add(layer);

            MarkerStyleBuilder builder = new MarkerStyleBuilder();

            builder.Bitmap = Bitmap;
            builder.Size   = 20;

            // Add marker
            MapPos position = BaseProjection.FromWgs84(new MapPos(24.646469, 59.426939));
            Marker marker   = new Marker(position, builder.BuildStyle());

            source.Add(marker);

            // Custom popup
            PopupStyleBuilder popupBuilder = new PopupStyleBuilder();

            popupBuilder.SetAttachAnchorPoint(0.5f, 0);

            // Initialize our custom handler, cf. class below
            MyCustomPopupHandler handler = new MyCustomPopupHandler();

            CustomPopup popup = new CustomPopup(marker, popupBuilder.BuildStyle(), handler);

            popup.SetAnchorPoint(-1.0f, 0.0f);
            source.Add(popup);
        }
        void AddMarker(string title, string subtitle, float latitude, float longitude)
        {
            // Define the location of the marker, it must be converted to base map coordinate system
            MapPos location = MapView.Options.BaseProjection.FromWgs84(new MapPos(longitude, latitude));

            // Load default market style
            MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder();

            // Add the label to the Marker
            positionMarker = new Marker(location, markerBuilder.BuildStyle());

            // Define label what is shown when you click on marker, with default style
            var balloonBuilder = new BalloonPopupStyleBuilder();
            positionLabel = new BalloonPopup(positionMarker, balloonBuilder.BuildStyle(), title, subtitle);

            // Add the marker and label to the layer
            markerSource.Add(positionMarker);
            markerSource.Add(positionLabel);

            // Center the map in the current location
            MapView.FocusPos = location;

            // Zoom in the map in the current location
            MapView.Zoom = 19f;
        }
        void OnLocationUpdate(object sender, LocationUpdatedEventArgs e)
        {
            double latitude = e.Location.Coordinate.Latitude;
            double longitude = e.Location.Coordinate.Longitude;

            string title = "Your current location";
            string description = latitude.To4Decimals() + ", " + longitude.To4Decimals();

            MapPos location = MapView.Options.BaseProjection.FromWgs84(new MapPos(longitude, latitude));

            if (IsMarkerSet) {
                markerLabel.Description = description;
                positionMarker.Geometry = new PointGeometry(location);
                return;
            }

            // Load default market style
            MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();

            // Add the label to the Marker
            positionMarker = new Marker(location, markerStyleBuilder.BuildStyle());

            // Define label what is shown when you click on marker, with default style
            var builder = new BalloonPopupStyleBuilder();
            markerLabel = new BalloonPopup(positionMarker, builder.BuildStyle(), title, description);

            // Add the marker and label to the layer
            markerSource.Add(positionMarker);
            markerSource.Add(markerLabel);

            // Center the map in the current location
            MapView.FocusPos = location;

            // Zoom in the map in the current location
            MapView.Zoom = 19f;
        }
Example #29
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Create PackageManager instance for dealing with offline packages
            var packageFolder = new File(GetExternalFilesDir(null), "routingpackages");

            if (!(packageFolder.Mkdirs() || packageFolder.IsDirectory))
            {
                Log.Fatal("Could not create package folder!");
            }

            packageManager = new CartoPackageManager(ManagerSource, packageFolder.AbsolutePath);

            PackageListener = new RoutingPackageListener(packageManager, downloadablePackages);
            packageManager.PackageManagerListener = PackageListener;
            packageManager.Start();

            // Fetch list of available packages from server.
            // Note that this is asynchronous operation
            // and listener will be notified via onPackageListUpdated when this succeeds.
            packageManager.StartPackageListDownload();

            // create offline routing service connected to package manager
            offlineRoutingService = new PackageManagerRoutingService(packageManager);

            // Create additional online routing service that will be used
            // when offline package is not yet downloaded or offline routing fails
            onlineRoutingService = new CartoOnlineRoutingService(ServiceSource);

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

            // Set route listener
            MapListener = new RouteMapEventListener();
            MapView.MapEventListener = MapListener;

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

            markerBuilder.Bitmap           = CreateBitmap(Resource.Drawable.olmarker);
            markerBuilder.HideIfOverlapped = false;
            markerBuilder.Size             = 30;
            markerBuilder.Color            = new Carto.Graphics.Color(Android.Graphics.Color.Green);

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

            markerBuilder.Color = new Carto.Graphics.Color(Android.Graphics.Color.Red);

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

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

            markerBuilder.Color  = new Carto.Graphics.Color(Android.Graphics.Color.White);
            markerBuilder.Bitmap = CreateBitmap(Resource.Drawable.direction_up);
            instructionUp        = markerBuilder.BuildStyle();

            markerBuilder.Bitmap = CreateBitmap(Resource.Drawable.direction_upthenleft);
            instructionLeft      = markerBuilder.BuildStyle();

            markerBuilder.Bitmap = CreateBitmap(Resource.Drawable.direction_upthenright);
            instructionRight     = markerBuilder.BuildStyle();

            // Style for instruction balloons
            balloonBuilder = new BalloonPopupStyleBuilder();
            balloonBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4);

            // Finally animate map to Estonia
            MapView.FocusPos = BaseProjection.FromWgs84(new MapPos(25.662893, 58.919365));
            MapView.Zoom     = 7;

            Alert("Long-press on map to set route start and finish");
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AddBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            // Create PackageManager instance for dealing with offline packages
            string folder = Utils.GetDocumentDirectory("routingpackages");

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
                Console.WriteLine("Directory: Does not exist... Creating");
            }
            else
            {
                Console.WriteLine("Directory: Exists");
            }

            packageManager  = new CartoPackageManager(ROUTING_PACKAGEMANAGER_SOURCE, folder);
            PackageListener = new RoutingPackageListener(packageManager, downloadablePackages);

            packageManager.PackageManagerListener = PackageListener;

            // Fetch list of available packages from server.
            // Note that this is asynchronous operation
            // and listener will be notified via onPackageListUpdated when this succeeds.
            packageManager.StartPackageListDownload();

            // Create offline routing service connected to package manager
            offlineRoutingService = new PackageManagerRoutingService(packageManager);

            // Create additional online routing service that will be used
            // when offline package is not yet downloaded or offline routing fails
            onlineRoutingService = new CartoOnlineRoutingService(ROUTING_SERVICE_SOURCE);

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

            MapListener = new RouteMapEventListener();
            MapView.MapEventListener = MapListener;

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

            markerStyleBuilder.Bitmap           = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("icons/olmarker.png"));
            markerStyleBuilder.HideIfOverlapped = false;
            markerStyleBuilder.Size             = 30;

            markerStyleBuilder.Color = new Carto.Graphics.Color(0, 255, 0, 255);

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

            markerStyleBuilder.Color = new Carto.Graphics.Color(255, 0, 0, 255);

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

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

            markerStyleBuilder.Color  = new Carto.Graphics.Color(255, 255, 255, 255);
            markerStyleBuilder.Bitmap = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("icons/direction_up.png"));
            instructionUp             = markerStyleBuilder.BuildStyle();

            markerStyleBuilder.Bitmap = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("icons/direction_upthenleft.png"));
            instructionLeft           = markerStyleBuilder.BuildStyle();

            markerStyleBuilder.Bitmap = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("icons/direction_upthenright.png"));

            instructionRight = markerStyleBuilder.BuildStyle();

            // Style for instruction balloons
            balloonPopupStyleBuilder = new BalloonPopupStyleBuilder();
            balloonPopupStyleBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4);

            // Finally animate map to Estonia
            MapView.FocusPos = BaseProjection.FromWgs84(new MapPos(25.662893, 58.919365));
            MapView.Zoom     = 7;

            Alert("Long-press on map to set route start and finish");
        }
        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 #32
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            mapView.Layers.Add(baseLayer);


            // create PackageManager instance for dealing with offline packages
            var packageFolder = new File(GetExternalFilesDir(null), "routingpackages");

            if (!(packageFolder.Mkdirs() || packageFolder.IsDirectory))
            {
                Log.Fatal("Could not create package folder!");
            }

            packageManager = new NutiteqPackageManager(ROUTING_PACKAGEMANAGER_SOURCE, packageFolder.AbsolutePath);
            packageManager.PackageManagerListener = new RoutingPackageListener(this);
            packageManager.Start();

            // fetch list of available packages from server. Note that this is asynchronous operation and listener will be notified via onPackageListUpdated when this succeeds.
            packageManager.StartPackageListDownload();

            // create offline routing service connected to package manager
            offlineRoutingService = new PackageManagerRoutingService(packageManager);

            // create additional online routing service that will be used when offline package is not yet downloaded or offline routing fails
            onlineRoutingService = new NutiteqOnlineRoutingService(ROUTING_SERVICE_SOURCE);

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


            // set route listener
            RouteMapEventListener mapListener = new RouteMapEventListener(this);

            mapView.MapEventListener = mapListener;

            // create markers for start & end, and a layer for them
            MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();

            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.olmarker));
            markerStyleBuilder.HideIfOverlapped = false;
            markerStyleBuilder.Size             = 30;

            markerStyleBuilder.Color = new Nutiteq.Graphics.Color(Android.Graphics.Color.Green);

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


            markerStyleBuilder.Color = new Nutiteq.Graphics.Color(Android.Graphics.Color.Red);

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

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

            markerStyleBuilder.Color  = new Nutiteq.Graphics.Color(Android.Graphics.Color.White);
            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.direction_up));
            instructionUp = markerStyleBuilder.BuildStyle();

            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.direction_upthenleft));
            instructionLeft = markerStyleBuilder.BuildStyle();

            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.direction_upthenright));

            instructionRight = markerStyleBuilder.BuildStyle();

            // style for instruction balloons
            balloonPopupStyleBuilder = new BalloonPopupStyleBuilder();
            balloonPopupStyleBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4);

            // finally animate map to Estonia
            mapView.FocusPos = baseProjection.FromWgs84(new MapPos(25.662893, 58.919365));
            mapView.Zoom     = 7;

            Toast.MakeText(ApplicationContext, "Long-press on map to set route start and finish", ToastLength.Long).Show();
        }
Example #33
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 #34
0
        static Marker GetMarker(Projection projection, MapPos position, Bitmap image)
        {
            //TODO
            //Bitmap androidMarkerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
            //com.carto.graphics.Bitmap markerBitmap = BitmapUtils.createBitmapFromAndroidBitmap(androidMarkerBitmap);

            // Create marker style
            MarkerStyleBuilder builder = new MarkerStyleBuilder();
            builder.Bitmap = image;
            builder.Size = 30;

            MarkerStyle style = builder.BuildStyle();

            // Create and return marker
            return new Marker(projection.FromWgs84(position), style);
        }