Exemple #1
0
        internal static BitmapDescriptor ToNative(this XImage image)
        {
            switch (image.Source)
            {
            default:
                return(null);

            case BaiduMaps.ImageSource.File:
                //return BitmapDescriptorFactory.FromFile(image.FileName);
                return(BitmapDescriptorFactory.FromPath(image.FileName));

            case ImageSource.Bundle:
                return(BitmapDescriptorFactory.FromAsset(image.BundleName));

            case ImageSource.Resource:
            {
                //Resource.Drawable.q10660 not include .mp3
                //int rsid = (int)typeof(Resource.Drawable).GetField(image.ResourceName).GetValue(null);
                //return BitmapDescriptorFactory.FromResource(rsid);
                //var rsid = Xamarin.Forms.Platform.Android.ResourceManager.g(image.ResourceId);
                return(BitmapDescriptorFactory.FromResource(image.ResourceId));
            }

            case ImageSource.Stream:
                return(BitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(image.Stream)));
            }
        }
        // Automatically called when new pin is added to map
        protected override MarkerOptions CreateMarker(Pin annotation)
        {
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(annotation.Position.Latitude, annotation.Position.Longitude));
            marker.SetTitle(annotation.Label);
            marker.SetIcon(BitmapDescriptorFactory.FromAsset(annotation.Address)); // Address is actually the image name for the pin
            return(marker);
        }
Exemple #3
0
 private void ResetPrevioslySelectedMarker()
 {
     //todo : This should reset to the default icon for the pin (right now the icon is hard coded)
     if (_previouslySelectedMarker != null)
     {
         _previouslySelectedMarker.SetIcon(
             BitmapDescriptorFactory.FromAsset(String.Format("{0}.png", _previouslySelectedPin.PinIcon)));
         _previouslySelectedMarker = null;
     }
 }
Exemple #4
0
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);
            marker.SetIcon(BitmapDescriptorFactory.FromAsset("BusStop_blue.png"));
            return(marker);
        }
 private void Initialize()
 {
     if (!string.IsNullOrEmpty(Pushpin.Icon))
     {
         MarkerOptions.SetIcon(BitmapDescriptorFactory.FromAsset(Pushpin.Icon));
     }
     else
     {
         MarkerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker());
     }
 }
Exemple #6
0
        //--------------------------------------------------------------------
        // SUPPORT METHODS FOR EXTERNAL METHODS
        //--------------------------------------------------------------------

        private void AddBridge(GeoLocation location)
        {
            // add marker
            var markerOptions = new MarkerOptions();

            markerOptions.SetPosition(new LatLng(location.Latitude, location.Longitude));
            markerOptions.SetTitle(location.Locality);
            markerOptions.SetIcon(BitmapDescriptorFactory.FromAsset("bridge32.png"));
            Marker marker = map.AddMarker(markerOptions);

            bridgeMarkers.Add(marker);
        }
Exemple #7
0
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            CustomPin customPin = GetCustomPin(pin);

            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);

            marker.SetIcon(BitmapDescriptorFactory.FromAsset($"m{customPin.NumMoments}.png"));
            //marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueMagenta));//.FromResource(Resource.Drawable.pin));
            return(marker);
        }
Exemple #8
0
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var androidMapView = (MapView)Control;

            if (e.PropertyName.Equals("CenterOnPosition"))
            {
                CenterOnLocation(new LatLng(_customMap.CenterOnPosition.Latitude, _customMap.CenterOnPosition.Longitude),
                                 _customMap.CameraFocusYOffset);
            }

            if (e.PropertyName.Equals("VisibleRegion") && !_isDrawnDone)
            {
                androidMapView.Map.Clear();

                androidMapView.Map.MarkerClick      += HandleMarkerClick;
                androidMapView.Map.MapClick         += HandleMapClick;
                androidMapView.Map.MyLocationEnabled = _customMap.IsShowingUser;

                //The footer overlays the zoom controls
                androidMapView.Map.UiSettings.ZoomControlsEnabled = false;

                var formsPins = _customMap.CustomPins;

                foreach (var formsPin in formsPins)
                {
                    var markerWithIcon = new MarkerOptions();

                    markerWithIcon.SetPosition(new LatLng(formsPin.Position.Latitude, formsPin.Position.Longitude));
                    markerWithIcon.SetTitle(formsPin.Label);
                    markerWithIcon.SetSnippet(formsPin.Address);

                    if (!string.IsNullOrEmpty(formsPin.PinIcon))
                    {
                        markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromAsset(String.Format("{0}.png", formsPin.PinIcon)));
                    }
                    else
                    {
                        markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
                    }

                    androidMapView.Map.AddMarker(markerWithIcon);
                }

                _isDrawnDone = true;
            }
        }
Exemple #9
0
        private void desenharRadar(RadarPin radar)
        {
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(radar.Pin.Position.Latitude, radar.Pin.Position.Longitude));
            marker.SetTitle(radar.Pin.Label);
            marker.SetSnippet(radar.Pin.Address);

            marker.SetRotation((float)radar.Sentido);
            switch (radar.Tipo)
            {
            case RadarTipoEnum.RadarFixo:
                marker.SetIcon(BitmapDescriptorFactory.FromAsset("radares/" + radar.Imagem));
                break;

            case RadarTipoEnum.SemaforoComRadar:
                marker.SetIcon(BitmapDescriptorFactory.FromAsset("radares/radar_40_semaforo.png"));
                break;

            case RadarTipoEnum.SemaforoComCamera:
                marker.SetIcon(BitmapDescriptorFactory.FromAsset("radares/semaforo.png"));
                break;

            case RadarTipoEnum.RadarMovel:
                marker.SetIcon(BitmapDescriptorFactory.FromAsset("radares/radar_movel.png"));
                break;

            case RadarTipoEnum.PoliciaRodoviaria:
                marker.SetIcon(BitmapDescriptorFactory.FromAsset("radares/policiarodoviaria.png"));
                break;

            case RadarTipoEnum.Lombada:
                marker.SetIcon(BitmapDescriptorFactory.FromAsset("radares/lombada.png"));
                break;

            case RadarTipoEnum.Pedagio:
                marker.SetIcon(BitmapDescriptorFactory.FromAsset("radares/pedagio.png"));
                break;
            }

            map.AddMarker(marker);
        }
        public void AddFromAsset(View view)
        {
            if (hMap == null)
            {
                return;
            }
            if (null != overlay)
            {
                overlay.Remove();
            }
            Log.Debug(TAG, "addFromAsset: ");
            GroundOverlayOptions options = new GroundOverlayOptions().Position(MapUtils.FRANCE2, 50, 50)
                                           .InvokeImage(BitmapDescriptorFactory.FromAsset("HuaweiIcon.png"));

            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);
        }
Exemple #11
0
        internal static BitmapDescriptor ToNative(this XImage image)
        {
            switch (image.Source)
            {
            default:
                return(null);

            case ImageSource.File:
                //return BitmapDescriptorFactory.FromFile(image.FileName);
                return(BitmapDescriptorFactory.FromPath(image.FileName));

            case ImageSource.Bundle:
                return(BitmapDescriptorFactory.FromAsset(image.BundleName));

            //case ImageSource.Resource:
            //return BitmapDescriptorFactory.FromResource

            case ImageSource.Stream:
                return(BitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(image.Stream)));
            }
        }
Exemple #12
0
        private BitmapDescriptor GetIcon(CustomPin pin)
        {
            string iconName = "vehicle_bubble_13_";

            var vehicleState = Provider.Instance.VehicleStates.Find(vs => vs.vehicleId == pin.Vehicle.vehicleId);

            if (!vehicleState.ignition)
            {
                iconName += "blue";
            }
            else if (vehicleState.speed < 5)
            {
                iconName += "orange";
            }
            else
            {
                iconName += "green";
            }

            iconName += ".png";
            return(BitmapDescriptorFactory.FromAsset(iconName));
        }
        private void SetMyCurrentMapLocation()
        {
            if (_map != null && _currentLocation != null)
            {
                _map.Clear();
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(_currentLocation);
                markerOpt1.SetTitle("My Target Location");
                BitmapDescriptor icon = BitmapDescriptorFactory.FromAsset("Spot.png");
                markerOpt1.SetIcon(icon);
                _map.AddMarker(markerOpt1);

                //MarkerOptions markerOpt2 = new MarkerOptions();
                //markerOpt2.SetPosition(_currentLatLon);
                //markerOpt2.SetTitle("Passchendaele");
                //_map.AddMarker(markerOpt2);

                // We create an instance of CameraUpdate, and move the map to it.
                //CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLng(_currentLatLon);
                //_map.MoveCamera(cameraUpdate);
            }
        }
Exemple #14
0
        public void setMarkers()
        {
            _map.Clear();
            if (spawnList != null)
            {
                for (int i = 0; i < spawnList.Count; i++)
                {
                    LatLng        tempPosition = new LatLng(spawnList[i]["spawnLatitude"], spawnList[i]["spawnLongitude"]);
                    MarkerOptions options      = new MarkerOptions().
                                                 SetPosition(tempPosition);
                    _map.AddMarker(options);
                }
            }
            BitmapDescriptor icon = BitmapDescriptorFactory.FromAsset("15minuteman.bmp");

            LatLng        currentLatLng = new LatLng(currentLat, currentLong);
            MarkerOptions playerOption  = new MarkerOptions()
                                          .SetPosition(currentLatLng)
                                          .SetIcon(icon)
                                          .SetTitle("Player");

            _map.AddMarker(playerOption);
        }