Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            _mapView = FindViewById<MapView>(Resource.Id.mapview);
            _mapView.SetTileSource(TileSourceFactory.DefaultTileSource);
            _mapView.SetBuiltInZoomControls(true);

            _mapController = _mapView.Controller;
            _mapController.SetZoom(25);

            var centreOfMap = new GeoPoint(51496994, -134733);
            _mapController.SetCenter(centreOfMap);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            _mapView = FindViewById <MapView>(Resource.Id.mapview);
            _mapView.SetTileSource(TileSourceFactory.DefaultTileSource);
            _mapView.SetBuiltInZoomControls(true);

            _mapController = _mapView.Controller;
            _mapController.SetZoom(25);

            var centreOfMap = new GeoPoint(51496994, -134733);

            _mapController.SetCenter(centreOfMap);
        }
Exemplo n.º 3
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            SupportActionBar.DisplayOptions = (int)ActionBarDisplayOptions.ShowCustom;
            SupportActionBar.SetCustomView(Resource.Layout.ActionBar_Moses);
            _sos        = SupportActionBar.CustomView.FindViewById <RelativeLayout>(Resource.Id.sos);
            _myLocation = SupportActionBar.CustomView.FindViewById <RelativeLayout>(Resource.Id.where_i);
            _layers     = SupportActionBar.CustomView.FindViewById <RelativeLayout>(Resource.Id.layers);

            _sos.Click += delegate(object sender, EventArgs args)
            {
                Toast.MakeText(this, "Help me!!!!", ToastLength.Long).Show();
            };
            _layers.Click += delegate(object sender, EventArgs args)
            {
                AlertDialog.Builder builderSingle = new AlertDialog.Builder(this);
                builderSingle.SetTitle("Type");

                ArrayAdapterWithIcon arrayAdapter = new ArrayAdapterWithIcon(
                    this,
                    Android.Resource.Layout.select_dialog_singlechoice_material);
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.tse_tse
                });
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.grass
                });
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.water
                });
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.fire
                });
                builderSingle.SetNegativeButton("Cancel", NegativeHandler);
                builderSingle.SetAdapter(arrayAdapter, this);
                builderSingle.Show();
            };
            _myLocation.Click += delegate(object sender, EventArgs args)
            {
                _mapController.SetCenter(_centreOfMap);
            };
            //StyleInterpreter interpreter = null;
            try
            {
                bool isTile = true;
                //List<OsmGeo> osm = null;
                if (isTile)
                {
                    _mapView = FindViewById <MapView>(Resource.Id.mapview);
                    _mapView.SetTileSource(TileSourceFactory.DefaultTileSource);
                    _mapView.SetBuiltInZoomControls(true);
                    //_mapView.SetUseDataConnection(false);

                    _provider = new CustomLocationProvider(this);
                    _provider.StartLocationProvider(new MyLocationNewOverlay(this, _mapView));

                    //List<OverlayItem> overlayItemArray = new List<OverlayItem>();
                    //OverlayItem olItem = new OverlayItem("Here", "SampleDescription", new GeoPoint(34.878039, -10.650));
                    //overlayItemArray.Add(olItem);
                    //olItem.SetMarker(Resources.GetDrawable(Resource.Drawable.cloud));
                    //overlayItemArray.Add(new OverlayItem("Hi", "You're here", new GeoPoint(34.888039, -10.660)));


                    DefaultResourceProxyImpl defaultResourceProxyImpl = new DefaultResourceProxyImpl(this);
                    //ItemizedIconOverlay myItemizedIconOverlay = new ItemizedIconOverlay(overlayItemArray, null, defaultResourceProxyImpl);
                    //_mapView.Overlays.Add(myItemizedIconOverlay);

                    //PathOverlay myPath = new PathOverlay(Color.Red, this);
                    //myPath.AddPoint(new GeoPoint(34.878039, -10.650));
                    //myPath.AddPoint(new GeoPoint(34.888039, -10.660));
                    //_mapView.Overlays.Add(myPath);

                    _mapController = _mapView.Controller;
                    _mapController.SetZoom(6);

                    _mapController.SetCenter(_centreOfMap);

                    _geoService = new CouchDbGeoObjectsService();

                    //var firstPoint = ((GeoJSON.Net.Geometry.Point) points.Features[0].Geometry);
                    var firstPoint = new OsmSharp.Geo.Geometries.Point(new OsmSharp.Math.Geo.GeoCoordinate(33, -10));
                    //double x = ((GeographicPosition) firstPoint.Coordinates).Latitude;
                    //double y = ((GeographicPosition)firstPoint.Coordinates).Longitude;
                    //List<OverlayItem> overlayItemArray = new List<OverlayItem>();
                    //OverlayItem olItem = new OverlayItem("Here", "SampleDescription", new GeoPoint(x, y));
                    //overlayItemArray.Add(olItem);
                    //olItem.SetMarker(Resources.GetDrawable(Resource.Drawable.cloud));

                    //ItemizedIconOverlay newPoints = new ItemizedIconOverlay(overlayItemArray, null, defaultResourceProxyImpl);
                    //_mapView.Overlays.Add(newPoints);
                }
                else
                {
                    /*List<OsmGeo> osm = await _service.DownloadArea(34.878039, -10.465, 36, -9.077);
                     * if (osm != null)
                     * {
                     * Native.Initialize();
                     *
                     * // initialize map.
                     * var map = new Map();
                     * interpreter = new MapCSSInterpreter(css);
                     *
                     * IDataSourceReadOnly source = new MemoryDataSource(osm.ToArray());
                     * var layer = map.AddLayerOsm(source, interpreter);
                     *
                     * _mapView = new MapView(this, new MapViewSurface(this));
                     * _mapView.Map = map;
                     * _mapView.MapMaxZoomLevel = 17; // limit min/max zoom because MBTiles sample only contains a small portion of a map.
                     * _mapView.MapMinZoomLevel = 1;
                     * _mapView.MapTilt = 0;
                     * _mapView.MapCenter = new GeoCoordinate(-9.2, 36);
                     * _mapView.MapZoom = 2;
                     * _mapView.MapAllowTilt = false;
                     *
                     * //OsmSharp.Data.SQLite.SQLiteConnectionBase sqLiteConnection = new SQLiteConnection("osmMap");
                     *
                     * frame.AddView(_mapView);
                     * var textLabel = FindViewById<TextView>(Resource.Id.text_label);
                     * textLabel.Text = "Изображение подгрузилось";
                     * Toast.MakeText(this, "Read success", ToastLength.Long).Show();
                     * }
                     * else
                     * {
                     * Toast.MakeText(this, "OSM is null", ToastLength.Long).Show();
                     * }*/
                }
            }
            catch (Exception exception)
            {
                Toast.MakeText(this, exception.Message, ToastLength.Long).Show();
                SetContentView(Resource.Layout.Main);
            }
        }