Exemplo n.º 1
0
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            extendedMap = (ExtendedMap)Element;
            mapView = Control as MapView;
            map = mapView.Map;

            map.MarkerClick+= HandleMarkerClick;

            // Pin tıklanınca sağalta açılan menüyü engellemek için
            map.UiSettings.MapToolbarEnabled = true;
            map.UiSettings.MyLocationButtonEnabled = true;

            if (extendedMap.isOverlayNeeded) {
                LatLng southwest = new LatLng (extendedMap.sw.Latitude, extendedMap.sw.Longitude);
                LatLng northeast = new LatLng (extendedMap.ne.Latitude, extendedMap.ne.Longitude);

                LatLngBounds bounds = new LatLngBounds (southwest, northeast);

                string url = extendedMap.overlayURL;//"http://www.mgm.gov.tr/mobile/mblhrt/data/radar/MAX--_6100_P00.png";

                Bitmap objBitmap = GetImageBitmapFromUrl (url);

                BitmapDescriptor objBitmapDescriptor = BitmapDescriptorFactory.FromBitmap (objBitmap);
                GroundOverlayOptions objGroundOverlayOptions = new GroundOverlayOptions ().PositionFromBounds (bounds)/*.Position (objMapPosition, 100000)*/.InvokeImage (objBitmapDescriptor);

                map.AddGroundOverlay (objGroundOverlayOptions);

                //For freeing memory
                objBitmap.Recycle ();
            }

            for (int i = 0; i < extendedMap.pinDatas.Count; i++) {
                var markerWithIcon = new MarkerOptions ();
                markerWithIcon.SetPosition (new LatLng (extendedMap.pinDatas[i].lat, extendedMap.pinDatas[i].lng));
                markerWithIcon.SetTitle (i.ToString());
                /*markerWithIcon.SetTitle ("aa");
                markerWithIcon.SetSnippet ("bb");*/
                int resID = Resources.GetIdentifier (extendedMap.pinDatas [i].icon, "drawable" , "com.app1001.bluemart");
                //System.Diagnostics.Debug.WriteLine (resID);
                markerWithIcon.SetIcon(BitmapDescriptorFactory.FromResource(resID));
                map.AddMarker (markerWithIcon);
            }

            //Add Pins

            //map.SetInfoWindowAdapter(this);
            map.UiSettings.RotateGesturesEnabled = false;
        }
Exemplo n.º 2
0
        public MapView(RootPage parent, UserClass mUserModel)
        {
            this.mUserModel = mUserModel;
            InitializeComponent ();
            mParent = parent;
            NavigationPage.SetHasNavigationBar (this, false);

            //InitalizeMemberVariables ();
            pinDatas = new List<PinData>();
            /*pinDatas.Add (new PinData(25.082742, 55.147174,"bm_pin","Dubai Marina BlueMart"));
            pinDatas.Add (new PinData(25.099536, 55.178529,"bm_pin","Tecom BlueMart"));
            pinDatas.Add (new PinData(25.094988, 55.172659,"bm_pin","Greens BlueMart"));*/
            pinDatas.Add (new PinData(25.049560, 55.205282,"bm_pin","Blue Mart JVC"));
            var map = new ExtendedMap (new Position (25.20, 55.26), 20, pinDatas,this);

            /*var map = new Map(
                MapSpan.FromCenterAndRadius(
                    new Position(25.20,55.26), Distance.FromMiles(20))) {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var position = new Position(25.082742, 55.147174);
            var pin = new Pin {
                Type = PinType.Place,
                Position = position,
                Label = "Blue Mart Supermarket",
                Address = "Dubai Marina, Dubai - UAE"
            };
            pin.Clicked += (object sender, EventArgs e) =>
            {
                OnPinClicked(0);
            };
            map.Pins.Add(pin);

            position = new Position(25.099536, 55.178529);
            pin = new Pin {
                Type = PinType.Place,
                Position = position,
                Label = "Blue Mart",
                Address = "Tecom, Dubai - UAE"
            };
            pin.Clicked += (object sender, EventArgs e) =>
            {
                OnPinClicked(1);
            };
            map.Pins.Add(pin);

            position = new Position(25.046035, 55.232205);
            pin = new Pin {
                Type = PinType.Place,
                Position = position,
                Label = "Blue Mart",
                Address = "Motor City, Dubai - UAE"
            };
            pin.Clicked += (object sender, EventArgs e) =>
            {
                OnPinClicked(2);
            };
            map.Pins.Add(pin);
            */
            StartShopingButton = new Button { Text = "Choose nearest bluemart" , BackgroundColor= Color.White, BorderWidth=0, TextColor = MyDevice.RedColor};
            StartShopingButton.Clicked += OnStartShopingButtonClicked;
            StartShopingButton.IsEnabled=false;

            Content = new StackLayout {
                Spacing = 0,
                Children = {
                    map,
                    StartShopingButton
                }};
        }