Exemplo n.º 1
0
 public static MGLCoordinateBounds ToCLRegion(this LatLngBounds pos)
 {
     return(new MGLCoordinateBounds {
         ne = pos.NorthEast.ToCLCoordinate(),
         sw = pos.SouthWest.ToCLCoordinate()
     });
 }
Exemplo n.º 2
0
        public static Community IsInCyclesCommunity(LatLng pointLatLng)
        {
            var builder = new LatLngBounds.Builder();

            if (CyclesCommunities == null)
            {
                return(null);
            }
            foreach (Community community in CyclesCommunities)
            {
                if (community == null)
                {
                    continue;
                }
                foreach (LatLng latLngSet in community.PolygonCoordinates)
                {
                    if (latLngSet != null)
                    {
                        builder.Include(latLngSet);
                    }
                }

                LatLngBounds polygonBounds = builder.Build();
                if (polygonBounds.Contains(pointLatLng))
                {
                    return(community);
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        public void DarZoom(LatLngBounds bounds, int margem)
        {
            CameraUpdate camera = CameraUpdateFactory.NewLatLngBounds(bounds, margem);


            Mapa.MoveCamera(camera);
        }
Exemplo n.º 4
0
        public void Refresh(List <Option> points)
        {
            this.mapView.Map.Clear();
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            foreach (var point in points)
            {
                var latLng = new LatLng(point.Lat, point.Lng);
                builder = builder.Include(latLng);
                BitmapDescriptor bitmap = BitmapDescriptorFactory.FromResource(Resource.Drawable.red_location);
                //构建MarkerOption,用于在地图上添加Marker
                OverlayOptions option = new MarkerOptions()
                                        .InvokePosition(latLng)
                                        .InvokeTitle(point.Title)
                                        .Anchor(0.5f, 0.5f)
                                        .Draggable(true)
                                        .ScaleX(0.5f)
                                        .ScaleY(0.5f)
                                        .InvokeIcon(bitmap);

                ////在地图上添加Marker,并显示
                this.mapView.Map.AddOverlay(option);
            }

            LatLngBounds    latlngBounds = builder.Build();
            MapStatusUpdate u            = MapStatusUpdateFactory.NewLatLngBounds(latlngBounds, mapView.Width, mapView.Height);

            mapView.Map.AnimateMapStatus(u);
        }
        private async void ShowPOI(object sender, GoogleMap.MapLongClickEventArgs e)
        {
            foreach (var point in pointsOfInterest)
            {
                point.Remove();
            }
            pointsOfInterest.Clear();

            LatLngBounds bounds = e.Point.GetBoundingBox(8000);

            var geocoder = new Geocoder(this);
            var results  = await geocoder.GetFromLocationNameAsync("Starbucks", 5,
                                                                   bounds.Southwest.Latitude, bounds.Southwest.Longitude,
                                                                   bounds.Northeast.Latitude, bounds.Northeast.Longitude);

            foreach (var result in results)
            {
                var markerOptions = new MarkerOptions()
                                    .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan))
                                    .SetPosition(new LatLng(result.Latitude, result.Longitude))
                                    .SetTitle(result.FeatureName)
                                    .SetSnippet(GetAdress(result));

                pointsOfInterest.Add(map.AddMarker(markerOptions));
            }
        }
Exemplo n.º 6
0
        async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
            var bounds = new LatLngBounds(
                new LatLng(37.7897, -119.5073),
                new LatLng(37.6744, -119.6815)
                );

            var offlineResion = new OfflinePackRegion
            {
                Bounds           = bounds,
                MinimumZoomLevel = 10,
                MaximumZoomLevel = 20,
                StyleURL         = map.MapStyle.UrlString
            };

            offlineService.OfflinePackProgressChanged += OfflineService_OfflinePackProgressChanged;
            var offlinePack = await offlineService.DownloadMap(offlineResion, new Dictionary <string, string> {
                { "regionName", "SImple Offline Region" }
            });

            if (offlinePack != null)
            {
                offlineService.RequestPackProgress(offlinePack);
            }
        }
Exemplo n.º 7
0
        public void OnMapReady(GoogleMap googleMap)
        {
            LatLng latlng = null;

            this.Gmap = googleMap;
            Gmap.UiSettings.ZoomControlsEnabled = true;
            Gmap.UiSettings.ZoomGesturesEnabled = true;

            LatLngBounds.Builder builder = new LatLngBounds.Builder();

            _auditDetailList   = manageTemplate.GetAllAudit();
            _auditTemplateList = manageTemplate.GetTemplates();
            foreach (AuditDetails auditDetail in _auditDetailList)
            {
                string[] gpsCoordinates = auditDetail.GPSCoordinate.Split(',');
                if (gpsCoordinates.Count() > 0)
                {
                    latlng = new LatLng(Convert.ToDouble(gpsCoordinates[0]), Convert.ToDouble(gpsCoordinates[1]));
                    MarkerOptions options         = new MarkerOptions().SetPosition(latlng).SetAlpha(auditDetail.Id);
                    var           templatedetails = _auditTemplateList.Find(t => t.Id == auditDetail.TemplateId);
                    options.SetTitle(templatedetails.Name);
                    options.SetSnippet(auditDetail.Location + " - " + DateTime.Today.ToShortDateString());

                    Gmap.AddMarker(options);
                    builder.Include(latlng);
                }
            }

            LatLngBounds bounds = builder.Build();
            CameraUpdate cu     = CameraUpdateFactory.NewLatLngBounds(bounds, Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels, 120);

            googleMap.MoveCamera(cu);

            Gmap.InfoWindowClick += Gmap_InfoWindowClick;
        }
Exemplo n.º 8
0
        public bool OnClusterClick(ICluster cluster)
        {
            // Show a toast with some info when the cluster is clicked.
            while (cluster.Items.GetEnumerator().MoveNext())
            {
                var person = cluster.Items.GetEnumerator().Current as Person;
                Toast.MakeText(this, cluster.Size + "(including " + person.name + ")", ToastLength.Short).Show();
            }

            // Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
            // inside of bounds, then animate to center of the bounds.

            // Create the builder to collect all essential cluster items for the bounds.
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            foreach (IClusterItem item in cluster.Items)
            {
                builder.Include(item.Position);
            }
            // Get the LatLngBounds
            LatLngBounds bounds = builder.Build();

            // Animate camera to the bounds
            try
            {
                getMap().AnimateCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 100));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Sets the route calculation data
        /// </summary>
        /// <param name="route">The PCL route</param>
        /// <param name="routeResult">The rourte api result</param>
        private void SetRouteData(TKRoute route, GmsRouteResult routeResult)
        {
            var latLngBounds = new LatLngBounds(
                new LatLng(routeResult.Bounds.SouthWest.Latitude, routeResult.Bounds.SouthWest.Longitude),
                new LatLng(routeResult.Bounds.NorthEast.Latitude, routeResult.Bounds.NorthEast.Longitude));

            var apiSteps       = routeResult.Legs.First().Steps;
            var steps          = new TKRouteStep[apiSteps.Count()];
            var routeFunctions = (IRouteFunctions)route;


            for (int i = 0; i < steps.Length; i++)
            {
                steps[i] = new TKRouteStep();
                var stepFunctions = (IRouteStepFunctions)steps[i];
                var apiStep       = apiSteps.ElementAt(i);

                stepFunctions.SetDistance(apiStep.Distance.Value);
                stepFunctions.SetInstructions(apiStep.HtmlInstructions);
            }
            routeFunctions.SetSteps(steps);
            routeFunctions.SetDistance(routeResult.Legs.First().Distance.Value);
            routeFunctions.SetTravelTime(routeResult.Legs.First().Duration.Value);

            routeFunctions.SetBounds(
                MapSpan.FromCenterAndRadius(
                    latLngBounds.Center.ToPosition(),
                    Distance.FromKilometers(
                        new Position(latLngBounds.Southwest.Latitude, latLngBounds.Southwest.Longitude)
                        .DistanceTo(
                            new Position(latLngBounds.Northeast.Latitude, latLngBounds.Northeast.Longitude)) / 2)));
            routeFunctions.SetIsCalculated(true);
        }
Exemplo n.º 10
0
        protected virtual void RegionDidChangeAnimated(MGLMapView mapView, bool animated)
        {
            // TODO Set back to Forms
            Element.ZoomLevel = mapView.ZoomLevel;
            //            Element.Pitch = mapView.Camera.Pitch;
            //            Element.RotatedDegree = mapView.Camera.Heading;
            //            Element?.RegionDidChangeCommand?.Execute(animated);
            var cameraMovedCommand = Element?.CameraMovedCommand;

            if (cameraMovedCommand?.CanExecute(null) == true)
            {
                var camera = new CameraPosition(
                    map.CenterCoordinate.ToLatLng(),
                    map.ZoomLevel,
                    map.Camera.Pitch,
                    map.Camera.Heading);
                cameraMovedCommand.Execute(camera);
            }

            var nxBounds = new LatLngBounds()
            {
                NorthEast = new LatLng(mapView.VisibleCoordinateBounds.ne.Latitude, mapView.VisibleCoordinateBounds.ne.Longitude),
                SouthWest = new LatLng(mapView.VisibleCoordinateBounds.sw.Latitude, mapView.VisibleCoordinateBounds.sw.Longitude)
            };

            Element.DidBoundariesChangedCommand?.Execute(nxBounds);
        }
Exemplo n.º 11
0
    public void OnShowPlaceAutocompleterPicker()
    {
        // Mode in which to show autocomplete: fullscreen or overlay
        const PlaceAutocomplete.Mode mode = PlaceAutocomplete.Mode.Fullscreen;

        // Filter places to cities only
        const PlaceAutocomplete.AutocompleteFilter filter = PlaceAutocomplete.AutocompleteFilter.Cities;

        // limit results to Australia
        const string countryCode = "AU";

        // limit search results in Sydney area
        var boundsBias = new LatLngBounds(
            new LatLng(-33.880490, 151.184363),
            new LatLng(-33.858754, 151.229596));

        PlaceAutocomplete.ShowPlaceAutocomplete(place =>
        {
            placeText.text = place.ToString();
        },
                                                error =>
        {
            var message    = "Picking place failed, message: " + error;
            placeText.text = message;
            Debug.Log(message);
        }, mode, filter, countryCode, boundsBias);
    }
Exemplo n.º 12
0
        /// <summary>
        /// Render the route planning result
        /// </summary>
        /// <param name="paths">paths</param>
        /// <param name="latLngBounds">latLngBounds</param>
        private void renderRoute(List <List <LatLng> > paths, LatLngBounds latLngBounds)
        {
            if (paths == null || paths.Count <= 0 || paths.ElementAt(0).Count <= 0)
            {
                return;
            }

            for (int i = 0; i < paths.Count; i++)
            {
                List <LatLng>   path    = paths.ElementAt(i);
                PolylineOptions options = new PolylineOptions().InvokeColor(Color.Blue).InvokeWidth(5);
                foreach (LatLng latLng in path)
                {
                    options.Add(latLng);
                }

                Polyline polyline = hMap.AddPolyline(options);
                mPolylines.Add(polyline);
            }

            AddOriginMarker(paths.ElementAt(0).ElementAt(0));
            AddDestinationMarker(paths.ElementAt(0).ElementAt(paths.ElementAt(0).Count - 1));

            if (null != latLngBounds)
            {
                CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(latLngBounds, 5);
                hMap.MoveCamera(cameraUpdate);
            }
            else
            {
                hMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(paths.ElementAt(0).ElementAt(0), 13));
            }
        }
Exemplo n.º 13
0
        public void OnMapReady(GoogleMap googleMap)
        {
            try
            {
                var markers = new List <MarkerOptions>();
                foreach (var place in ViewModel.Places)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(place.Latitude, place.Longitude));
                    marker.SetTitle(place.Name);
                    googleMap.AddMarker(marker);
                    markers.Add(marker);
                }
                if (markers.Count == 0)
                {
                    return;
                }
                var builder = new LatLngBounds.Builder();

                foreach (var marker in markers)
                {
                    builder.Include(marker.Position);
                }

                LatLngBounds bounds  = builder.Build();
                int          padding = 145; // offset from edges of the map in pixels
                var          cu      = CameraUpdateFactory.NewLatLngBounds(bounds, padding);
                googleMap.AnimateCamera(cu);
            }
            catch (Exception e)
            {
                App.LogOutLn(e.StackTrace, GetType().Name);
            }
        }
Exemplo n.º 14
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         bounds = await LatLngBounds.CreateAsync(map1.JsRuntime);
     }
 }
Exemplo n.º 15
0
        public static GlobalSettings Load()
        {
            GlobalSettings settings;

            if (File.Exists(ConfigFile))
            {
                SettingsToSave set;
                //if the file exists, load the Settings
                var input = File.ReadAllText(ConfigFile);

                var jsonSettings = new JsonSerializerSettings();
                jsonSettings.Converters.Add(new StringEnumConverter {
                    CamelCaseText = true
                });
                jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace;
                jsonSettings.DefaultValueHandling   = DefaultValueHandling.Populate;
                set      = JsonConvert.DeserializeObject <SettingsToSave>(input, jsonSettings);
                settings = new GlobalSettings();
                Port     = set.Port;
                //UseTrackemon = set.UseTrackemon;
                UsePokeSnipers             = set.UsePokeSnipers;
                UsePokewatchers            = set.UsePokewatchers;
                UsePokezz                  = set.UsePokezz;
                UsePokemonGoIVClub         = set.UsePokemonGoIVClub;
                UsePokeSnipe               = set.UsePokeSnipers;
                VerifyOnSkiplagged         = set.VerifyOnSkiplagged;
                RemoveAfter                = set.RemoveAfter;
                ShowLimit                  = Math.Max(set.ShowLimit, 1);
                PokeSnipers2Exe            = set.PokeSnipers2Exe;
                UseFilter                  = set.UseFilter;
                UseGeoLocationBoundsFilter = set.UseGeoLocationBoundsFilter;
                GeoLocationBounds          = set.GeoLocationBounds;
                AppTheme           = set.AppTheme;
                IsServer           = set.IsServer;
                IsManaged          = set.IsManaged;
                ServerHost         = set.ServerHost;
                ServerPort         = set.ServerPort;
                OutgoingServerPort = set.OutgoingServerPort;
                ShareBotCaptures   = set.ShareBotCaptures;
                BotWebSocketPorts  = set.BotWebSocketPorts;
                VerifiedOnly       = set.VerifiedOnly;
            }
            else
            {
                settings = new GlobalSettings();
            }
            PokekomsToFeedFilter = LoadFilter();
            var firstRun = !File.Exists(ConfigFile);

            Save();

            if (firstRun ||
                Port == 0
                )
            {
                Log.Error($"Invalid configuration detected. \nPlease edit {ConfigFile} and try again");
                return(null);
            }
            return(settings);
        }
Exemplo n.º 16
0
        // gets all gyms at the given location and calculate a radius
        public async Task <JsonValue> GetPlacesAsJSON(double lat, double lng, LatLngBounds llb)
        {
            var radius = LatLngDist.distance(llb.Northeast.Latitude, llb.Northeast.Longitude, llb.Southwest.Latitude, llb.Southwest.Longitude, 'K') * 1000 / 2;

            Log.Debug("JSON", radius + "");
            return(await GetPlacesAsJSON(lat, lng, radius));
        }
Exemplo n.º 17
0
        private async void GetRutas(int id_mandado)
        {
            List <Manboss_mandados_ruta> rutas = await core.GetRutas(id_mandado);

            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            foreach (Manboss_mandados_ruta ruta in rutas)
            {
                markerOpt1 = new MarkerOptions();
                LatLng lugar = new LatLng(ruta.Latitud, ruta.Longitud);
                builder.Include(lugar);
                markerOpt1.SetPosition(lugar);
                markerOpt1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.mandado));
                _map.AddMarker(markerOpt1);
            }
            //Mover camera
            LatLngBounds bounds       = builder.Build();
            CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 300);

            _map.MoveCamera(cameraUpdate);
            //Dibujar ruta
            List <Manboss_repartidores_ubicaciones> ubicaciones = await core.GetUbicaciones(id_mandado);

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(0x6604B7FF);
            foreach (var position in rutas)
            {
                polylineOptions.Add(new LatLng(position.Latitud, position.Longitud));
            }
            foreach (var position in ubicaciones)
            {
                polylineOptions.Add(new LatLng(position.latitud, position.longitud));
            }
            _map.AddPolyline(polylineOptions);
        }
Exemplo n.º 18
0
 public static bool IsValid(LatLngBounds @this)
 {
     return(null != @this && (LatLngAlt.IsValid(@this.southwest) && LatLngAlt.IsValid(@this.northeast)) ||
            (@this.north.HasValue && @this.south.HasValue && @this.east.HasValue && @this.west.HasValue &&
             double.IsFinite(@this.north.Value) && double.IsFinite(@this.south.Value) && double.IsFinite(@this.east.Value) && double.IsFinite(@this.west.Value) &&
             @this.north.Value != LatLngAlt.DoubleZero && @this.south.Value != LatLngAlt.DoubleZero && @this.east.Value != LatLngAlt.DoubleZero && @this.west.Value != LatLngAlt.DoubleZero));
 }
        public bool OnClusterClick(ICluster p0)
        {
            // zoom to expand the cluster
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            foreach (var item in p0.Items)
            {
                var clusterMarker = item as ClusterMarker;
                if (clusterMarker.Position != null)
                {
                    builder.Include(clusterMarker.Position);
                }
            }
            LatLngBounds bounds = builder.Build();

            try
            {
                googleMap.AnimateCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 100));
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            return(true);
        }
Exemplo n.º 20
0
        public void OnMapReady(GoogleMap googleMap)
        {
            List <List <Localization> > Localizations = new List <List <Localization> >();

            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            if (Training.SerializedLocalizations != null && Training.SerializedLocalizations.Length > 0)
            {
                IFormatter formatter = new BinaryFormatter();
                using (MemoryStream stream = new MemoryStream(Training.SerializedLocalizations))
                {
                    Localizations = formatter.Deserialize(stream) as List <List <Localization> >;
                }
            }
            foreach (var path in Localizations)
            {
                PolylineOptions options = new PolylineOptions()
                                          .InvokeColor((new Color(105, 121, 176, 200).ToArgb()))
                                          .InvokeWidth(20);
                foreach (var point in path)
                {
                    options.Add(new LatLng(point.Latitude, point.Longitude));
                    builder.Include(new LatLng(point.Latitude, point.Longitude));
                }
                googleMap.AddPolyline(options);
            }
            LatLngBounds bounds = builder.Build();
            // begin new code:
            int width   = Resources.DisplayMetrics.WidthPixels;
            int height  = Resources.DisplayMetrics.HeightPixels;
            int padding = (int)(width * 0.05);

            CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, width, height, padding);

            googleMap.AnimateCamera(cameraUpdate);
        }
Exemplo n.º 21
0
        public static SKMapSpan ToMapSpan(this LatLngBounds self)
        {
            double latSpan  = self.Northeast.Latitude - self.Southwest.Latitude;
            double longSpan = self.Northeast.Longitude - self.Southwest.Longitude;

            return(new SKMapSpan(self.Center.ToPosition(), latSpan * 0.5, longSpan * 0.5));
        }
Exemplo n.º 22
0
 public State(string name, LatLng latLng)
 {
     this.name = name;
     latLongs  = new List <LatLng>();
     latLongs.Add(latLng);
     bounds = new LatLngBounds(latLng, latLng);
 }
Exemplo n.º 23
0
        private void DrawMarkers(TripDetails tripDetail)
        {
            // Draw Markers
            string[] origin      = tripDetail.originLatLng.Split(',');
            string[] destination = tripDetail.destinationLatLng.Split(',');
            LatLng   o           = new LatLng(double.Parse(origin[0]), double.Parse(origin[1]));
            LatLng   d           = new LatLng(double.Parse(destination[0]), double.Parse(destination[1]));

            mMap.AddMarker(new MarkerOptions().SetPosition(o).SetTitle("Origin"));
            mMap.AddMarker(new MarkerOptions().SetPosition(d).SetTitle("Destination"));
            if (tripDetail.TripPassengers != null)
            {
                foreach (TripPassenger tp in tripDetail.TripPassengers)
                {
                    string[] w        = tp.originLatLng.Split(',');
                    LatLng   waypoint = new LatLng(double.Parse(w[0]), double.Parse(w[1]));
                    mMap.AddMarker(new MarkerOptions().SetPosition(waypoint).SetTitle("waypoint"));
                }
            }
            // Zoom map to the set padding
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            builder.Include(o);
            builder.Include(d);
            LatLngBounds bounds  = builder.Build();
            int          padding = 100;
            CameraUpdate cu      = CameraUpdateFactory.NewLatLngBounds(bounds, padding);

            mMap.AnimateCamera(cu);
        }
Exemplo n.º 24
0
        private void ShowRouteOverview()
        {
            NativeMap.Clear();

            PolylineOptions selectedRoutePolyline = new PolylineOptions();

            selectedRoutePolyline.InvokeColor(Resource.Color.colorPrimaryDark);
            selectedRoutePolyline.InvokeWidth(20f);

            LatLng[] allRoutePoints = _xamap.SelectedRoute.Legs
                                      .SelectMany(leg => leg.Points)
                                      .Select(point => new LatLng(point.Latitude, point.Longitude))
                                      .ToArray();

            selectedRoutePolyline.Add(allRoutePoints);
            NativeMap.AddPolyline(selectedRoutePolyline);

            LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
            LatLngBounds         routeBounds   = allRoutePoints
                                                 .Aggregate(boundsBuilder, (builder, latLng) => builder.Include(latLng))
                                                 .Build();

            CameraUpdate routeOverviewMapUpdate = CameraUpdateFactory.NewLatLngBounds(routeBounds, 50);

            NativeMap.AnimateCamera(routeOverviewMapUpdate);
        }
Exemplo n.º 25
0
        private async Task Agregar_marcadores()
        {
            if (GlobalValues.arr_lugares.Count > 0)
            {
                LatLngBounds.Builder         builder = new LatLngBounds.Builder();
                List <Manboss_mandados_ruta> puntos  = new List <Manboss_mandados_ruta>();
                foreach (Lugares aux in GlobalValues.arr_lugares)
                {
                    MarkerOptions markerOpt1 = new MarkerOptions();
                    LatLng        lugar      = new LatLng(aux.Latitud, aux.Longitud);
                    builder.Include(lugar);
                    markerOpt1.SetPosition(lugar);
                    markerOpt1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.mandado));
                    _map.AddMarker(markerOpt1);
                    Manboss_mandados_ruta posicion = new Manboss_mandados_ruta();
                    posicion.Latitud  = aux.Latitud;
                    posicion.Longitud = aux.Longitud;
                    puntos.Add(posicion);
                }
                //polyline
                await Obtener_direcciones(puntos);

                //Mover camera
                LatLngBounds bounds       = builder.Build();
                CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 300);
                _map.MoveCamera(cameraUpdate);
                //Revisar mínimo de ubicaciones
                Lugares primero = GlobalValues.arr_lugares.First();
                if (GlobalValues.arr_lugares.Count >= primero.Min)
                {
                    btn_pagar_mandado.Visibility = ViewStates.Visible;
                }
            }
        }
Exemplo n.º 26
0
        public void OnMapReady(GoogleMap googleMap)
        {
            var Map = googleMap;
            IList <MarkerOptions> markers = new List <MarkerOptions>();
            var trips = AppStore.Instance.User.Trips;

            Map.Clear();
            foreach (var trip in trips)
            {
                var places = trip.Places;
                foreach (var place in places)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(place.Latitude, place.Longitude));
                    marker.SetTitle(place.Name);
                    Map.AddMarker(marker);
                    markers.Add(marker);
                    //Map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(place.Latitude, place.Longitude), 15));
                }
            }
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            foreach (var marker in markers)
            {
                builder.Include(marker.Position);
            }
            LatLngBounds bounds  = builder.Build();
            int          padding = 240; // offset from edges of the map in pixels
            CameraUpdate cu      = CameraUpdateFactory.NewLatLngBounds(bounds, padding);

            Map.AnimateCamera(cu);
        }
 public PlacesAutocompleteAdapter(Context context, GoogleApiClient googleApiClient,
                                  LatLngBounds bounds, AutocompleteFilter filter)
 {
     this.context            = context;
     this.googleApiClient    = googleApiClient;
     this.bounds             = bounds;
     this.autoCompleteFilter = filter;
 }
Exemplo n.º 28
0
        //Launch place picker
        void _pickAPlaceButton_Click(object sender, EventArgs e)
        {
            var          mapBuilder = new PlacePicker.IntentBuilder();
            LatLngBounds boundary   = new LatLngBounds(_southWestCorner, _northEastCorner);

            mapBuilder.SetLatLngBounds(boundary);
            StartActivityForResult(mapBuilder.Build(this), 1);
        }
Exemplo n.º 29
0
        private void GenerateRoute(string json)
        {
            try
            {
                JSONObject jsonObject = new JSONObject(json);
                JSONArray  routes     = jsonObject.OptJSONArray("routes");
                if (null == routes || routes.Length() == 0)
                {
                    return;
                }
                JSONObject route = routes.GetJSONObject(0);

                // get route bounds
                JSONObject bounds = route.OptJSONObject("bounds");
                if (null != bounds && bounds.Has("southwest") && bounds.Has("northeast"))
                {
                    JSONObject southwest = bounds.OptJSONObject("southwest");
                    JSONObject northeast = bounds.OptJSONObject("northeast");
                    LatLng     sw        = new LatLng(southwest.OptDouble("lat"), southwest.OptDouble("lng"));
                    LatLng     ne        = new LatLng(northeast.OptDouble("lat"), northeast.OptDouble("lng"));
                    mLatLngBounds = new LatLngBounds(sw, ne);
                }

                // get paths
                JSONArray paths = route.OptJSONArray("paths");
                for (int i = 0; i < paths.Length(); i++)
                {
                    JSONObject    path  = paths.OptJSONObject(i);
                    List <LatLng> mPath = new List <LatLng>();

                    JSONArray steps = path.OptJSONArray("steps");
                    for (int j = 0; j < steps.Length(); j++)
                    {
                        JSONObject step = steps.OptJSONObject(j);

                        JSONArray polyline = step.OptJSONArray("polyline");
                        for (int k = 0; k < polyline.Length(); k++)
                        {
                            if (j > 0 && k == 0)
                            {
                                continue;
                            }
                            JSONObject line   = polyline.GetJSONObject(k);
                            double     lat    = line.OptDouble("lat");
                            double     lng    = line.OptDouble("lng");
                            LatLng     latLng = new LatLng(lat, lng);
                            mPath.Add(latLng);
                        }
                    }
                    mPaths.Add(mPath);
                }
                mHandler.SendEmptyMessage(0);
            }
            catch (JSONException e)
            {
                Log.Error(TAG, "JSONException" + e.ToString());
            }
        }
Exemplo n.º 30
0
        private void AnimateCameraBbox(LatLngBounds bounds, int animationTime, int[] padding)
        {
            var position               = map.RetrieveMap().GetCameraForLatLngBounds(bounds, padding);
            var cameraUpdate           = CameraUpdateFactory.NewCameraPosition(position);
            var navigationCameraUpdate = new NavigationCameraUpdate(cameraUpdate);

            navigationCameraUpdate.SetMode(CameraUpdateMode.Override);
            map.RetrieveCamera().Update(navigationCameraUpdate, animationTime);
        }
Exemplo n.º 31
0
        /**
         * Generates boxes for a given route and distance
         *
         * @param {LatLng[]} vertices The vertices of the path over which to lay the grid
         * @param {Number} range The spacing of the grid cells.
         */
        private void _BuildGrid(List<LatLng> vertices, double range)
        {
            // Create a LatLngBounds object that contains the whole path
            LatLngBounds routeBounds = new LatLngBounds();

            logger.trace("_BuildGrid range: {0}", range);

            range *= GridFactor;

            logger.trace("vertices[0]" + vertices[0].ToString() + " vertices[" + (vertices.Count - 1) + "] " + vertices.ElementAt(vertices.Count - 1).ToString());

            for (int i = 0; i < vertices.Count; i++)
            {
                routeBounds.Extend(vertices[i]);
            }

            logger.trace("routeBounds " + routeBounds.ToString());

            // Find the center of the bounding box of the path
            LatLng routeBoundsCenter = routeBounds.GetCenter();

            logger.trace("routeBoundsCenter " + routeBoundsCenter.ToString());

            // Starting from the center define grid lines outwards vertically until they
            // extend beyond the edge of the bounding box by more than one cell
            this._latGrid.Add(routeBoundsCenter.Lat);
            LatLng rhumb = routeBoundsCenter.RhumbDestinationPoint(0, range);

            logger.trace("rhumb 1 " + rhumb.ToString());

            // Add lines from the center out to the north
            this._latGrid.Add(rhumb.Lat);
            for (int i = 2; this._latGrid[i - 2] < routeBounds.GetNorthEast().Lat; i++)
            {
                this._latGrid.Add(routeBoundsCenter.RhumbDestinationPoint(0, range * i).Lat);
            }

            logger.trace("pass1 latGrid size " + _latGrid.Count);

            // Add lines from the center out to the south  
            for (int i1 = 1; this._latGrid[1] > routeBounds.GetSouthWest().Lat; i1++)
            {
                this._latGrid.Insert(0, routeBoundsCenter.RhumbDestinationPoint(180, range * i1).Lat);
            }

            logger.trace("pass2 latGrid size " + _latGrid.Count);

            // Starting from the center define grid lines outwards horizontally until they
            // extend beyond the edge of the bounding box by more than one cell  
            this._lngGrid.Add(routeBoundsCenter.Lng);

            // Add lines from the center out to the east
            this._lngGrid.Add(routeBoundsCenter.RhumbDestinationPoint(90, range).Lng);
            for (int i2 = 2; this._lngGrid[i2 - 2] < routeBounds.GetNorthEast().Lng; i2++)
            {
                this._lngGrid.Add(routeBoundsCenter.RhumbDestinationPoint(90, range * i2).Lng);
            }

            logger.trace("pass1 lngGrid_ size " + _latGrid.Count);

            // Add lines from the center out to the west
            for (int i3 = 1; this._lngGrid[1] > routeBounds.GetSouthWest().Lng; i3++)
            {
                this._lngGrid.Insert(0, routeBoundsCenter.RhumbDestinationPoint(270, range * i3).Lng);
            }

            logger.trace("pass2 lngGrid_ size " + _latGrid.Count);

            // Create a two dimensional array representing this grid
            // this.grid_ = new int[this.lngGrid_.Count, this.latGrid_.Count];
            this._grid = new int[this._lngGrid.Count][]; // this.latGrid_.Count];

            for (var i = 0; i < this._lngGrid.Count; i++)
            {
                this._grid[i] = new int[this._latGrid.Count];
            }

        }
Exemplo n.º 32
0
 /**
  * Search for an existing box in an adjacent column to the given box that spans
  * the same set of rows and if one is found merge the given box into it. If one
  * is not found, append this box to the list of existing boxes.
  *
  * @param {LatLngBounds}  The box to merge
  */
 private void _MergeBoxesY(LatLngBounds box)
 {
     if (box != null)
     {
         for (int i = 0; i < this._boxesY.Count; i++)
         {
             if (Math.Abs(this._boxesY[i].GetNorthEast().Lat - box.GetSouthWest().Lat) < 0.001 &&
                 Math.Abs(this._boxesY[i].GetSouthWest().Lng - box.GetSouthWest().Lng) < 0.001 &&
                 Math.Abs(this._boxesY[i].GetNorthEast().Lng - box.GetNorthEast().Lng) < 0.001)
             {
                 this._boxesY[i].Extend(box.GetNorthEast());
                 return;
             }
         }
         this._boxesY.Add(box);
     }
 }