예제 #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);
        }
        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);
        }