protected override NativeGroundOverlay DeleteNativeItem(GroundOverlay outerItem)
        {
            var nativeOverlay = outerItem.NativeObject as NativeGroundOverlay;

            if (nativeOverlay == null)
            {
                return(null);
            }
            nativeOverlay.Remove();
            outerItem.NativeObject = null;

            return(nativeOverlay);
        }
 internal override void OnUpdateIcon(GroundOverlay outerItem, NativeGroundOverlay nativeItem)
 {
     if (outerItem.Icon != null && outerItem.Icon.Type == BitmapDescriptorType.View)
     {
         // If the pin has an IconView set this method will convert it into an icon for the marker
         TransformXamarinViewToAndroidBitmap(outerItem, nativeItem);
     }
     else
     {
         var factory          = _bitmapDescriptorFactory ?? DefaultBitmapDescriptorFactory.Instance;
         var nativeDescriptor = factory.ToNative(outerItem.Icon);
         nativeItem.SetImage(nativeDescriptor);
     }
 }
Exemplo n.º 3
0
        protected override NativeGroundOverlay CreateNativeItem(GroundOverlay outerItem)
        {
            var nativeOverlay = NativeGroundOverlay.GetGroundOverlay(
                outerItem.Bounds.ToCoordinateBounds(), outerItem.Icon.ToUIImage());

            nativeOverlay.Bearing  = outerItem.Bearing;
            nativeOverlay.Opacity  = 1 - outerItem.Transparency;
            nativeOverlay.Tappable = outerItem.IsClickable;
            nativeOverlay.ZIndex   = outerItem.ZIndex;

            outerItem.NativeObject = nativeOverlay;
            nativeOverlay.Map      = NativeMap;
            return(nativeOverlay);
        }
Exemplo n.º 4
0
        public async void OnLocationChanged(Location location)
        {
            _currentLocation = location;
            if (_currentLocation != null)
            {
                bool jump = Math.Abs(_currentLocation.Latitude - lat) > 1 || Math.Abs(_currentLocation.Longitude - lon) > 1;
                lat = _currentLocation.Latitude;
                lon = _currentLocation.Longitude;

                LatLng loc = new LatLng(lat, lon);

                CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(loc, 18);

                if (_map != null)
                {
                    if (jump)
                    {
                        _map.MoveCamera(cameraUpdate);
                    }
                    else
                    {
                        _map.AnimateCamera(cameraUpdate);
                    }
                }

                if (_myOverlay != null)
                {
                    _myOverlay.Position = loc;
                }
                else
                {
                    BitmapDescriptor     image = BitmapDescriptorFactory.FromResource(Resource.Drawable.gherkin);
                    GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions()
                                                                .Position(loc, bHeight / 4, bHeight / 4)
                                                                .InvokeImage(image);
                    _myOverlay = _map.AddGroundOverlay(groundOverlayOptions);
                }

                if (_enemyOverlay == null)
                {
                    BitmapDescriptor     image = BitmapDescriptorFactory.FromResource(Resource.Drawable.question);
                    GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions()
                                                                .Position(new LatLng(lat + 0.000001, lon + 0.000001), bHeight / 4, bHeight / 4)
                                                                .InvokeImage(image);
                    _enemyOverlay           = _map.AddGroundOverlay(groundOverlayOptions);
                    _enemyOverlay.Clickable = true;
                }
            }
        }
        protected override NativeGroundOverlay CreateNativeItem(GroundOverlay outerItem)
        {
            var opts = new GroundOverlayOptions()
                       .PositionFromBounds(outerItem.Bounds.ToLatLngBounds())
                       .Clickable(outerItem.IsClickable)
                       .InvokeBearing(outerItem.Bearing)
                       .InvokeImage(outerItem.Icon.ToBitmapDescriptor())
                       .InvokeTransparency(outerItem.Transparency);

            var overlay = NativeMap.AddGroundOverlay(opts);

            // associate pin with marker for later lookup in event handlers
            outerItem.NativeObject = overlay;
            return(overlay);
        }
Exemplo n.º 6
0
        public void GroundOverlayProducesId()
        {
            XElement element = new XElement("GroundOverlay",
                                            new XAttribute("id", "STS-122"),
                                            new XElement("TimeSpan",
                                                         new XElement("begin", "2007-12-06T16:31")));

            var groundOverlay = new GroundOverlay(element, m_document);

            groundOverlay.WritePacket();

            string result = m_stringWriter.ToString();

            StringAssert.Contains("\"id\":\"STS-122\"", result);
        }
Exemplo n.º 7
0
 private void PositionPolarBearGroundOverlay(LatLng position)
 {
     if (_polarBearOverlay == null)
     {
         BitmapDescriptor     image = BitmapDescriptorFactory.FromResource(Resource.Drawable.polarbear);
         GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions()
                                                     .Position(position, 150, 200)
                                                     .InvokeImage(image);
         _polarBearOverlay = _map.AddGroundOverlay(groundOverlayOptions);
     }
     else
     {
         _polarBearOverlay.Position = InMaui;
     }
 }
        private async Task AddOverlay()
        {
            _mapoverlay = await GroundOverlay.CreateAsync(map1.JsRuntime, "https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg", new LatLngBoundsLiteral()
            {
                North = 40.773941,
                South = 40.712216,
                East  = -74.12544,
                West  = -74.22655
            }, new GroundOverlayOptions()
            {
                Opacity = 0.5
            });

            await _mapoverlay.SetMap(map1.InteropObject);
        }
 private void PositionChicagoGroundOverlay(LatLng position)
 {
     if (_chicagoOverlay == null)
     {
         BitmapDescriptor     image = BitmapDescriptorFactory.FromResource(Resource.Drawable.monkey);
         GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions()
                                                     .Position(position, 150000, 200000)
                                                     .InvokeImage(image);
         _chicagoOverlay = _map.AddGroundOverlay(groundOverlayOptions);
     }
     else
     {
         _chicagoOverlay.Position = Location_Chicago;
     }
 }
 void PositionPolarBearGroundOverlay(LatLng position)
 {
     if (polarBearOverlay == null)
     {
         var polarBear            = BitmapDescriptorFactory.FromResource(Resource.Drawable.polarbear);
         var groundOverlayOptions = new GroundOverlayOptions()
                                    .InvokeImage(polarBear)
                                    .Anchor(0, 1)
                                    .Position(position, 150, 200);
         polarBearOverlay = googleMap.AddGroundOverlay(groundOverlayOptions);
     }
     else
     {
         polarBearOverlay.Position = InMaui;
     }
 }
Exemplo n.º 11
0
    public void OnClearMapClick()
    {
        if (_map == null)
        {
            return;
        }

        _map.Clear();
        // All the elements are now removed, we cannot access them any more
        _circle          = null;
        _marker          = null;
        _groundOverlay   = null;
        _polyline        = null;
        _coloradoPolygon = null;
        _heatmap         = null;
    }
Exemplo n.º 12
0
        protected void OnUpdateIconView(GroundOverlay outerItem, NativeGroundOverlay nativeItem)
        {
            if (outerItem?.Icon?.Type == BitmapDescriptorType.View && outerItem?.Icon?.View != null)
            {
                NativeMap.InvokeOnMainThread(() =>
                {
                    var iconView               = outerItem.Icon.View;
                    var nativeView             = Utils.ConvertFormsToNative(iconView, new CGRect(0, 0, iconView.WidthRequest, iconView.HeightRequest));
                    nativeView.BackgroundColor = UIColor.Clear;
                    //nativeItem.GroundAnchor = new CGPoint(iconView.AnchorX, iconView.AnchorY);
                    nativeItem.Icon = Utils.ConvertViewToImage(nativeView);

                    // Would have been way cooler to do this instead, but surprisingly, we can't do this on Android:
                    // nativeItem.IconView = nativeView;
                });
            }
        }
Exemplo n.º 13
0
        public void LatLonBoxProducesVertexPositions()
        {
            XElement element = new XElement("GroundOverlay",
                                            new XElement("LatLonBox",
                                                         new XElement("north", "90"),
                                                         new XElement("south", "-90"),
                                                         new XElement("east", "180"),
                                                         new XElement("west", "-180")));

            var groundOverlay = new GroundOverlay(element, m_document);

            groundOverlay.WritePacket();

            string result = m_stringWriter.ToString();

            StringAssert.Contains("\"vertexPositions\":{\"cartographicRadians\":[-3.141592653589793,1.5707963267948966,0,3.141592653589793,1.5707963267948966,0,3.141592653589793,-1.5707963267948966,0,-3.141592653589793,-1.5707963267948966,0]}", result);
        }
Exemplo n.º 14
0
        private static Feature CreateFeature(int index, bool id)
        {
            Feature output;
            int     type = index % 7;

            switch (type)
            {
            case 0:
                output = new Placemark();
                break;

            case 1:
                output = new Folder();
                break;

            case 2:
                output = new Document();
                break;

            case 3:
                output = new NetworkLink();
                break;

            case 4:
                output = new GroundOverlay();
                break;

            case 5:
                output = new ScreenOverlay();
                break;

            default:
                output = new PhotoOverlay();
                break;
            }

            if (id)
            {
                output.Id = "i" + index;
            }
            else
            {
                output.TargetId = "i" + index;
            }
            return(output);
        }
Exemplo n.º 15
0
        protected override NativeGroundOverlay DeleteNativeItem(GroundOverlay outerItem)
        {
            if (outerItem != null)
            {
                if (outerItem.NativeObject is NativeGroundOverlay)
                {
                    if (outerItem.NativeObject != null)
                    {
                        var nativeOverlay = outerItem.NativeObject as NativeGroundOverlay;
                        nativeOverlay.Map = null;

                        return(nativeOverlay);
                    }
                }
            }
            return(null);
        }
        private async void TransformXamarinViewToAndroidBitmap(GroundOverlay outerItem, NativeGroundOverlay nativeItem)
        {
            if (outerItem?.Icon?.Type == BitmapDescriptorType.View && outerItem.Icon?.View != null)
            {
                var iconView   = outerItem.Icon.View;
                var nativeView = await Utils.ConvertFormsToNative(
                    iconView,
                    new Rectangle(0, 0, (double)Utils.DpToPx((float)iconView.WidthRequest), (double)Utils.DpToPx((float)iconView.HeightRequest)),
                    Platform.Android.Platform.CreateRendererWithContext(iconView, _context));

                var otherView = new FrameLayout(nativeView.Context);
                nativeView.LayoutParameters = new FrameLayout.LayoutParams(Utils.DpToPx((float)iconView.WidthRequest), Utils.DpToPx((float)iconView.HeightRequest));
                otherView.AddView(nativeView);
                nativeItem.SetImage(await Utils.ConvertViewToBitmapDescriptor(otherView));
                //nativeItem.SetAnchor((float)iconView.AnchorX, (float)iconView.AnchorY);
                nativeItem.Visible = true;
            }
        }
        protected override NativeGroundOverlay CreateNativeItem(GroundOverlay outerItem)
        {
            var factory          = _bitmapDescriptorFactory ?? DefaultBitmapDescriptorFactory.Instance;
            var nativeDescriptor = factory.ToNative(outerItem.Icon);

            var opts = new GroundOverlayOptions()
                       .PositionFromBounds(outerItem.Bounds.ToLatLngBounds())
                       .Clickable(outerItem.IsClickable)
                       .InvokeBearing(outerItem.Bearing)
                       .InvokeImage(nativeDescriptor)
                       .InvokeTransparency(outerItem.Transparency)
                       .InvokeZIndex(outerItem.ZIndex);

            var overlay = NativeMap.AddGroundOverlay(opts);

            // associate pin with marker for later lookup in event handlers
            outerItem.NativeObject = overlay;
            return(overlay);
        }
Exemplo n.º 18
0
        public void GroundOverlayTimeSpanProducesAvailability()
        {
            XElement element = new XElement("GroundOverlay",
                                            new XElement("TimeSpan",
                                                         new XElement("begin", "2007-12-06T16:31")),
                                            new XElement("LatLonBox",
                                                         new XElement("north", "90"),
                                                         new XElement("south", "-90"),
                                                         new XElement("east", "180"),
                                                         new XElement("west", "-180")));

            var groundOverlay = new GroundOverlay(element, m_document);

            groundOverlay.WritePacket();

            string result = m_stringWriter.ToString();

            StringAssert.Contains("\"availability\":\"20071206T1631Z/99991231T24Z\"", result);
        }
Exemplo n.º 19
0
        private KMLRoot CreateKmlFeat()
        {
            KMLRoot kml  = new KMLRoot();
            Folder  fldr = new Folder("Test Folder");

            fldr.Add(new Folder("Sub Folder"));

            GroundOverlay g = new GroundOverlay();

            g.altitude     = 100;
            g.altitudeMode = AltitudeMode.relativeToGround;
            g.color        = Color.Blue;
            g.description  = "Cool overlay";

            fldr.Add(g);
            kml.Feature = fldr;

            return(kml);
        }
Exemplo n.º 20
0
        public void AltitudeModeAbsoluteChangesHeight()
        {
            XElement element = new XElement("GroundOverlay",
                                            new XElement("altitudeMode", "absolute"),
                                            new XElement("altitude", "1000"),
                                            new XElement("LatLonBox",
                                                         new XElement("north", "90"),
                                                         new XElement("south", "-90"),
                                                         new XElement("east", "180"),
                                                         new XElement("west", "-180")));

            var groundOverlay = new GroundOverlay(element, m_document);

            groundOverlay.WritePacket();

            string result = m_stringWriter.ToString();

            StringAssert.Contains("\"vertexPositions\":{\"cartographicRadians\":[-3.141592653589793,1.5707963267948966,1e3,3.141592653589793,1.5707963267948966,1e3,3.141592653589793,-1.5707963267948966,1e3,-3.141592653589793,-1.5707963267948966,1e3]}", result);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var newark  = new CLLocationCoordinate2D(40.742, -74.174);
            var camera  = CameraPosition.FromCamera(newark, 12, 0, 50);
            var mapView = MapView.FromCamera(RectangleF.Empty, camera);

            // Image from http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg
            var groundOverlay = new GroundOverlay()
            {
                Icon      = UIImage.FromBundle("newark_nj_1922.jpg"),
                Position  = newark,
                Bearing   = 0,
                ZoomLevel = 13.6f,
                Map       = mapView
            };

            View = mapView;
        }
        public void AddFromResource(View view)
        {
            if (hMap == null)
            {
                return;
            }
            if (null != overlay)
            {
                overlay.Remove();
            }
            Log.Debug(TAG, "AddFromResource: ");
            GroundOverlayOptions options = new GroundOverlayOptions().Position(MapUtils.FRANCE2, 50, 50)
                                           .InvokeImage(BitmapDescriptorFactory.FromResource(Resource.Drawable.niuyouguo));

            overlay = hMap.AddGroundOverlay(options);
            CameraPosition cameraPosition = new
                                            CameraPosition.Builder().Target(MapUtils.FRANCE2).Zoom(18).Bearing(0f).Tilt(0f).Build();
            CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            hMap.MoveCamera(cameraUpdate);
        }
Exemplo n.º 23
0
        public GroundOverlay GetGroundOverlay(string box)
        {
            GroundOverlay overlay   = new GroundOverlay();
            var           southWest = new Position(CoordinateFunctions.GetLatitudeCeilingFromBox(box),
                                                   CoordinateFunctions.GetLongitudeCeilingFromBox(box));
            var northEast = new Position(CoordinateFunctions.GetLatitudeFloorFromBox(box),
                                         CoordinateFunctions.GetLongitudeFloorFromBox(box));

            //var boxView = new MapBoxContentView();
            //overlay.Icon = BitmapDescriptorFactory.FromView(boxView);
            overlay.Icon = BitmapDescriptorFactory.FromView(new ContentView
            {
                WidthRequest  = 100,
                HeightRequest = 100,
                Content       = new Label {
                    Text = box
                }
            });
            overlay.Bounds       = new Bounds(southWest, northEast);
            overlay.Transparency = 0.5f;
            return(overlay);
        }
Exemplo n.º 24
0
        protected override NativeGroundOverlay CreateNativeItem(GroundOverlay outerItem)
        {
            var factory       = _imageFactory ?? DefaultImageFactory.Instance;
            var nativeOverlay = NativeGroundOverlay.GetGroundOverlay(
                outerItem.Bounds.ToCoordinateBounds(), factory.ToUIImage(outerItem.Icon));

            nativeOverlay.Bearing  = outerItem.Bearing;
            nativeOverlay.Opacity  = 1 - outerItem.Transparency;
            nativeOverlay.Tappable = outerItem.IsClickable;
            nativeOverlay.ZIndex   = outerItem.ZIndex;

            if (outerItem.Icon != null)
            {
                nativeOverlay.Icon = factory.ToUIImage(outerItem.Icon);
            }

            outerItem.NativeObject = nativeOverlay;
            nativeOverlay.Map      = outerItem.IsVisible ? NativeMap : null;

            OnUpdateIconView(outerItem, nativeOverlay);

            return(nativeOverlay);
        }
Exemplo n.º 25
0
        public void OnMapReady(GoogleMap googleMap)
        {
            _googleMap = googleMap;

            googleMap.MyLocationEnabled      = true;
            googleMap.MyLocationButtonClick += LocationButtonClick;

            googleMap.UiSettings.MapToolbarEnabled   = false;
            googleMap.UiSettings.ZoomControlsEnabled = true;
            googleMap.UiSettings.CompassEnabled      = true;

            SetUpLocation();

            //Set up current position/image
            BitmapDescriptor     image = BitmapDescriptorFactory.FromResource(Resource.Drawable.bluedot);
            GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions()
                                                        .Position(LocationToLatLong(_currentLocation), 10, 10)
                                                        .InvokeImage(image);

            _myOverlay = _googleMap.AddGroundOverlay(groundOverlayOptions);

            MoveCamera(_currentLocation);
        }
        public void OnMapReady(GoogleMap googleMap)
        {
            googleMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(NEWARK, 11));

            images.Clear();
            images.Add(BitmapDescriptorFactory.FromResource(Resource.Drawable.newark_nj_1922));
            images.Add(BitmapDescriptorFactory.FromResource(Resource.Drawable.newark_prudential_sunny));

            currentEntry = 0;

            groundOverlay = googleMap.AddGroundOverlay(new GroundOverlayOptions()
                                                       .InvokeImage(images [currentEntry])
                                                       .Anchor(0, 1)
                                                       .Position(NEWARK, 8600f, 6500f));

            transparencyBar.ProgressChanged += (sender, e) => {
                if (groundOverlay != null)
                {
                    groundOverlay.Transparency = (float)e.Progress / (float)TRANSPARENCY_MAX;
                }
            };

            googleMap.SetContentDescription("Google Map with ground overlay.");
        }
Exemplo n.º 27
0
 void AddGroundOverlay()
 {
     _groundOverlay = _map.AddGroundOverlay(DemoUtils.CreateInitialGroundOverlayOptions());
     CenterCamera(_groundOverlay.Position);
 }
Exemplo n.º 28
0
 internal override void OnUpdateIsClickable(GroundOverlay outerItem, NativeGroundOverlay nativeItem)
 {
     nativeItem.Clickable = outerItem.IsClickable;
 }
Exemplo n.º 29
0
 internal override void OnUpdateIcon(GroundOverlay outerItem, NativeGroundOverlay nativeItem)
 {
     nativeItem.SetImage(outerItem.Icon.ToBitmapDescriptor());
 }
Exemplo n.º 30
0
 internal override void OnUpdateBounds(GroundOverlay outerItem, NativeGroundOverlay nativeItem)
 {
     nativeItem.SetPositionFromBounds(outerItem.Bounds.ToLatLngBounds());
 }