Example #1
0
        public void FinishAddingMarkers()
        {
            try
            {
                shouldUpdateMetrics           = false;
                shouldUpdateMovingSegmentLine = false;

                var lastMarker = new Marker()
                {
                    Previous = MarkerList.Last(),
                    Position = MarkerList.First().Position,
                };

                Vector3 initialPos = MarkerList.Last().Position;
                Vector3 finalPos   = MarkerList.First().Position;

                perimeterDistance += Vector3.Distance(finalPos, initialPos);
                debugText.text     = perimeterDistance > 1 ? $"\n TOTAL: {Math.Round(perimeterDistance, 2)} mts." : $"\n TOTAL: {Math.Round(perimeterDistance, 2) * 100} cms.";

                BuildSegmentLine(initialPos, finalPos);
                movingSegmentLine.SetActive(false);

                MarkerList.Add(lastMarker);
                CreateMesh();
            }
            catch (Exception ex)
            {
                debugText.text = ex.Message;
            }
        }
Example #2
0
        public void CreateMarker()
        {
            try
            {
                GameObject prefab = Resources.Load($"Prefabs/Marker") as GameObject;
                CurrentMarker = Instantiate(prefab);

                var newMarker = new Marker()
                {
                    Previous = (MarkerList != null && MarkerList.Count > 0) ? MarkerList.Last() : null,
                    Position = CurrentMarker.transform.position,
                };

                MarkerList.Add(newMarker);
                shouldUpdateMovingSegmentLine = true;

                if (MarkerList.Count > 1)
                {
                    BuildSegmentLine(PreviousMarker.transform.position, CurrentMarker.transform.position);
                }

                shouldUpdateMetrics = true;
            }
            catch (Exception ex)
            {
                debugText.text = $"{ex.Message}";
            }
        }
Example #3
0
                void UpdateMap(bool result)
                {
                    if (GroupEntries.Count > 0)
                    {
                        // update our list and display
                        SearchResultPrefix.Text = ConnectStrings.GroupFinder_Neighborhood;

                        (ListView.Adapter as GroupArrayAdapter).SetSelectedRow(0);

                        // for the map, ensure it's valid, because Google Play can fail
                        if (Map != null)
                        {
                            Map.Clear( );
                            MarkerList.Clear( );

                            Android.Gms.Maps.Model.LatLngBounds.Builder builder = new Android.Gms.Maps.Model.LatLngBounds.Builder();

                            // add the source position
                            Android.Gms.Maps.Model.MarkerOptions markerOptions = new Android.Gms.Maps.Model.MarkerOptions();
                            Android.Gms.Maps.Model.LatLng        pos           = new Android.Gms.Maps.Model.LatLng(SourceLocation.Latitude, SourceLocation.Longitude);
                            markerOptions.SetPosition(pos);
                            markerOptions.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
                            builder.Include(pos);

                            Android.Gms.Maps.Model.Marker marker = Map.AddMarker(markerOptions);
                            MarkerList.Add(marker);

                            for (int i = 0; i < GroupEntries.Count; i++)
                            {
                                // add the positions to the map
                                markerOptions = new Android.Gms.Maps.Model.MarkerOptions();
                                pos           = new Android.Gms.Maps.Model.LatLng(GroupEntries[i].Latitude, GroupEntries[i].Longitude);
                                markerOptions.SetPosition(pos);
                                markerOptions.SetTitle(GroupEntries[i].Name);
                                markerOptions.SetSnippet(string.Format("{0:##.0} {1}", GroupEntries[i].DistanceFromSource, ConnectStrings.GroupFinder_MilesSuffix));

                                builder.Include(pos);

                                marker = Map.AddMarker(markerOptions);
                                MarkerList.Add(marker);
                            }

                            Android.Gms.Maps.Model.LatLngBounds bounds = builder.Build( );

                            int paddingInPixels = Math.Min(View.Width, (int)(View.Height * .1f));

                            CameraUpdate camPos = CameraUpdateFactory.NewLatLngBounds(bounds, paddingInPixels);
                            Map.AnimateCamera(camPos);

                            // show the info window for the first (closest) group
                            MarkerList[1].ShowInfoWindow( );
                        }
                    }
                    else
                    {
                        if (result == true)
                        {
                            // send the analytic and update our list
                            SearchResultPrefix.Text       = ConnectStrings.GroupFinder_NoGroupsFound;
                            SearchResultNeighborhood.Text = string.Empty;

                            (ListView.Adapter as GroupArrayAdapter).SetSelectedRow(-1);

                            // validate the map before using. Google Play can error
                            if (Map != null)
                            {
                                // no groups found, so move the camera to the default position
                                Android.Gms.Maps.Model.LatLng defaultPos = new Android.Gms.Maps.Model.LatLng(ConnectConfig.GroupFinder_DefaultLatitude, ConnectConfig.GroupFinder_DefaultLongitude);
                                CameraUpdate camPos = CameraUpdateFactory.NewLatLngZoom(defaultPos, ConnectConfig.GroupFinder_DefaultScale_Android);
                                Map.AnimateCamera(camPos);
                            }
                        }
                        else
                        {
                            // there was actually an error. Let them know.
                            SearchResultPrefix.Text       = ConnectStrings.GroupFinder_NetworkError;
                            SearchResultNeighborhood.Text = string.Empty;
                        }
                    }
                }