Пример #1
0
        public void OnMapReady(GoogleMap googleMap)
        {
            mMap = googleMap;
            LatLng       latlng = new LatLng(loc.Latitude, loc.Longitude); //Wijnhaven
            CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);

            mMap.MoveCamera(camera);
            MarkerOptions start = new MarkerOptions()
                                  .SetPosition(latlng)
                                  .SetTitle("Uw huidige locatie")
                                  .SetSnippet("U bevind zich hier")
                                  .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));

            mMap.AddMarker(start);
            MarkerFactory mFactory = new MarkerFactory(preLoad.csvFT.getMarkers());
            float         lowest   = 99999;

            for (Iterator iter = mFactory.getIterator(); iter.hasNext();)
            {
                FietsTrommel ft = iter.next();
                if (ft.xcoord.Length > 0 && ft.ycoord.Length > 0)
                {
                    double   lat    = Convert.ToDouble(ft.xcoord.Replace('.', ','));
                    double   lon    = Convert.ToDouble(ft.ycoord.Replace('.', ','));
                    Location fietsT = new Location("");
                    fietsT.Latitude  = lat;
                    fietsT.Longitude = lon;

                    if (fietsT.DistanceTo(loc) < 500)
                    {
                        LatLng        coords    = new LatLng(lat, lon);
                        MarkerOptions newMarker = new MarkerOptions()
                                                  .SetPosition(coords)
                                                  .SetTitle(ft.Straat)
                                                  .SetSnippet("Sinds: " + ft.Mutdatum)
                                                  .Draggable(true);

                        mMap.AddMarker(newMarker);
                    }
                    if (fietsT.DistanceTo(loc) < lowest)
                    {
                        lowest  = fietsT.DistanceTo(loc);
                        closest = ft;
                    }
                }
            }
            Location closestF = new Location("");
            double   closLat  = Convert.ToDouble(closest.xcoord.Replace('.', ','));
            double   closLon  = Convert.ToDouble(closest.ycoord.Replace('.', ','));

            closestF.Latitude  = closLat;
            closestF.Longitude = closLon;
        }
Пример #2
0
        public void OnMapReady(GoogleMap googleMap)
        {
            mMap = googleMap;
              LatLng latlng = new LatLng(loc.Latitude, loc.Longitude); //Wijnhaven
              CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);
              mMap.MoveCamera(camera);
              MarkerOptions start = new MarkerOptions()
               .SetPosition(latlng)
               .SetTitle("Uw huidige locatie")
               .SetSnippet("U bevind zich hier")
               .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));

              mMap.AddMarker(start);
              MarkerFactory mFactory = new MarkerFactory(preLoad.csvFT.getMarkers());
              float lowest = 99999;
              for (Iterator iter = mFactory.getIterator(); iter.hasNext();)
              {
            FietsTrommel ft = iter.next();
            if (ft.xcoord.Length > 0 && ft.ycoord.Length > 0)
            {
              double lat = Convert.ToDouble(ft.xcoord.Replace('.', ','));
              double lon = Convert.ToDouble(ft.ycoord.Replace('.', ','));
              Location fietsT = new Location("");
              fietsT.Latitude = lat;
              fietsT.Longitude = lon;

              if (fietsT.DistanceTo(loc) < 500)
              {
            LatLng coords = new LatLng(lat, lon);
            MarkerOptions newMarker = new MarkerOptions()
             .SetPosition(coords)
             .SetTitle(ft.Straat)
             .SetSnippet("Sinds: " + ft.Mutdatum)
             .Draggable(true);

            mMap.AddMarker(newMarker);
              }
              if (fietsT.DistanceTo(loc) < lowest)
              {
            lowest = fietsT.DistanceTo(loc);
            closest = ft;
              }
            }
              }
              Location closestF = new Location("");
              double closLat = Convert.ToDouble(closest.xcoord.Replace('.', ','));
              double closLon = Convert.ToDouble(closest.ycoord.Replace('.', ','));
              closestF.Latitude = closLat;
              closestF.Longitude = closLon;
        }