Example #1
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 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);
        }
        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);
        }