Exemplo n.º 1
0
        void AddMarkers()
        {
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to   = new GeoCoordinate(51.267797, 4.801362);

            _mapView.ClearMarkers();

            var       img     = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.marker);
            MapMarker marker1 = new MapMarker(this, from, MapControlAlignmentType.CenterBottom, img);

            _mapView.AddMarker(marker1);

            _mapView.AddMarker(to);
        }
        public override void LoadView()
        {
            base.LoadView();

            var camera = CameraPosition.FromCamera(latitude: 30.2652898,
                                                   longitude: -97.7386826,
                                                   zoom: 17,
                                                   bearing: 15,
                                                   viewingAngle: 15);

            mapView                   = MapView.FromCamera(View.Bounds, camera);
            mapView.MapType           = MapViewType.Normal;
            mapView.MyLocationEnabled = true;
            //mapView.Frame = View.Frame;

            var hiltonOptions = new MarkerOptions();

            hiltonOptions.Position = new MonoTouch.CoreLocation.CLLocationCoordinate2D(30.2652898, -97.7386826);
            hiltonOptions.Title    = "Evolve 2013";
            hiltonOptions.Snippet  = "Austin, TX";
            mapView.AddMarker(hiltonOptions);

            View.Add(mapView);

            satelliteSwitch       = new UISwitch();
            satelliteSwitch.Frame = new RectangleF(11.0f, 11.0f, satelliteSwitch.Frame.Width, satelliteSwitch.Frame.Height);
            satelliteSwitch.On    = false;
            View.Add(satelliteSwitch);

            currentLocNow        = UIButton.FromType(UIButtonType.RoundedRect);
            currentLocNow.Frame  = new RectangleF(50, 100, 100, 20);
            currentLocNow.Center = new PointF(View.Frame.Width / 2, View.Frame.Height - 20.0f);
            currentLocNow.SetTitle("ShowMyLoc", UIControlState.Normal);
            View.AddSubview(currentLocNow);
        }
Exemplo n.º 3
0
        void AddMarkers()
        {
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to   = new GeoCoordinate(51.267797, 4.801362);

            var box = new GeoCoordinateBox(from, to);

            _mapView.ClearMarkers();

            MapMarker marker;

            for (int idx = 0; idx < 20; idx++)
            {
                var pos = box.GenerateRandomIn();

                marker = new MapMarker(this, pos, MapControlAlignmentType.CenterBottom, this.Resources, Resource.Drawable.marker);
                var popupView = marker.AddNewPopup(300, 300);
                var textView  = new TextView(this.ApplicationContext);
                textView.Text     = "Some popup text here.";
                textView.TextSize = 10;
                textView.SetTextColor(global::Android.Graphics.Color.Black);
                popupView.AddView(textView);
                _mapView.AddMarker(marker);
            }
        }
Exemplo n.º 4
0
        public override void LoadView()
        {
            base.LoadView();

            CameraPosition camera = CameraPosition.FromCamera(37.797865, -122.402526, 6);

            mapView = MapView.FromCamera(RectangleF.Empty, camera);
            mapView.MyLocationEnabled = true;

            mapView.AddMarker(new MarkerOptions {
                Title    = "Xamarin HQ",
                Snippet  = "Where the magic happens.",
                Position = new CLLocationCoordinate2D(37.797865, -122.402526)
            });

            View = mapView;
        }
Exemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.MapView);

            mapView                  = FindViewById <MapView>(Resource.Id.mapview);
            mapView.StyleUrl         = Mapbox.Constants.Style.Emerald;
            mapView.CenterCoordinate = new LatLng(41.885, -87.679);
            mapView.ZoomLevel        = 11;

            mapView.OnCreate(bundle);

            mapView.AddMarker(new MarkerOptions()
                              .SetTitle("Test Marker")
                              .SetPosition(new LatLng(41.885, -87.679)));
        }
Exemplo n.º 6
0
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.Main);

            mapView = FindViewById<MapView> (Resource.Id.mapview);
            mapView.StyleUrl = Mapbox.Constants.Style.Emerald;
            mapView.CenterCoordinate = new LatLng (41.885, -87.679);
            mapView.ZoomLevel = 11;

            mapView.OnCreate (bundle);

            mapView.AddMarker (new MarkerOptions ()
                .SetTitle ("Test Marker")
                .SetPosition (new LatLng(41.885, -87.679)));         
        }
Exemplo n.º 7
0
        void AddMarkers()
        {
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to   = new GeoCoordinate(51.267797, 4.801362);

            var box = new GeoCoordinateBox(from, to);

            _mapView.ClearMarkers();

            MapMarker marker;

            for (int idx = 0; idx < 20; idx++)
            {
                var pos = box.GenerateRandomIn();
                marker = _mapView.AddMarker(pos);
                var popupTextView = new UITextView();
                popupTextView.Text            = "Hey, this is popup text!";
                popupTextView.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f);
                marker.AddPopup(popupTextView, 100, 100);
            }
        }
Exemplo n.º 8
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                MapView.Clear();

                foreach (var pin in this.MapControl.ExtendedPins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                    marker.SetTitle(pin.Pin.Label);
                    marker.SetSnippet(pin.Pin.Address);

                    if (MapControl.GetPinViewDelegate != null)
                    {
                        var formsView = MapControl.GetPinViewDelegate(pin);
                        marker = marker.Anchor((float)formsView.AnchorX, (float)formsView.AnchorY);
                        //var nativeView = Utils.ConvertFormsToNative (formsView, new Rectangle (0, 0, (double)Utils.DpToPx ((float)formsView.WidthRequest), (double)Utils.DpToPx ((float)formsView.HeightRequest)));
                        var nativeView = WMapAuxiliarRenderer.LiveMapRenderer.GetNativeView(formsView);
                        Utils.FixImageSourceOfImageViews(nativeView as Android.Views.ViewGroup);

                        var otherView = new FrameLayout(this.Context);
                        nativeView.LayoutParameters = new FrameLayout.LayoutParams(Utils.DpToPx((float)formsView.WidthRequest), Utils.DpToPx((float)formsView.HeightRequest));
                        otherView.AddView(nativeView);

                        var bitmap = Utils.ConvertViewToBitmap(otherView);
                        marker.SetIcon(BitmapDescriptorFactory.FromBitmap(bitmap));
                    }

                    MapView.AddMarker(marker);
                }
                isDrawn = true;
            }
        }
        public override void LoadView()
        {
            OsmSharp.Logging.Log.Enable();

            base.LoadView();

            // initialize a test-map.
            var map = new Map();

            map.AddLayer(new LayerScene(Scene2DLayered.Deserialize(
                                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.iOS.UI.Sample.wvl.map"),
                                            true)));

            // Perform any additional setup after loading the view, typically from a nib.
            MapView mapView = new MapView();

            _mapView = mapView;
            //mapViewAnimator = new MapViewAnimator (mapView);
            mapView.Map       = map;
            mapView.MapCenter = new GeoCoordinate(51.158075, 2.961545);             // gistel
//			mapView.MapTapEvent+= delegate(GeoCoordinate geoCoordinate) {
//				mapView.AddMarker(geoCoordinate).TouchDown  += MapMarkerClicked;
//			};

            mapView.MapMaxZoomLevel = 18;
            mapView.MapMinZoomLevel = 12;
            mapView.MapZoom         = 16;
            mapView.MapTilt         = 30;

            var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer(false);
            var graphDeserialized = routingSerializer.Deserialize(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.iOS.UI.Sample.wvl.routing"), true);

            _router = Router.CreateCHFrom(
                graphDeserialized, new CHRouter(graphDeserialized),
                new OsmRoutingInterpreter());

//			long before = DateTime.Now.Ticks;
//
//			var routeLocations = new GeoCoordinate[] {
//				new GeoCoordinate (50.8247730, 2.7524706),
//				new GeoCoordinate (50.8496394, 2.7301512),
//				new GeoCoordinate (50.8927741, 2.6138545),
//				new GeoCoordinate (50.8296363, 2.8869437)
//			};
//
//			var routerPoints = new RouterPoint[routeLocations.Length];
//			for (int idx = 0; idx < routeLocations.Length; idx++) {
//				routerPoints [idx] = router.Resolve (Vehicle.Car, routeLocations [idx]);
//
//				mapView.AddMarker (routeLocations [idx]);
//			}
//			OsmSharp.Routing.TSP.RouterTSPWrapper<RouterTSPAEXGenetic> tspRouter = new OsmSharp.Routing.TSP.RouterTSPWrapper<RouterTSPAEXGenetic> (
//				new RouterTSPAEXGenetic (10, 20), router);
//
//			Route route = tspRouter.CalculateTSP (Vehicle.Car, routerPoints);
//
//			long after = DateTime.Now.Ticks;
//
//			OsmSharp.Logging.Log.TraceEvent("OsmSharp.Android.UI.MapView", System.Diagnostics.TraceEventType.Information,"Routing & TSP in {0}ms",
//			                                new TimeSpan (after - before).TotalMilliseconds);
            // 51.160477" lon="2.961497
            GeoCoordinate point1 = new GeoCoordinate(51.158075, 2.961545);
            GeoCoordinate point2 = new GeoCoordinate(51.190503, 3.004793);

            //GeoCoordinate point1 = new GeoCoordinate(51.159132, 2.958755);
            //GeoCoordinate point2 = new GeoCoordinate(51.160477, 2.961497);
            RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, point1);
            RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, point2);
            Route       route1       = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);

            _enumerator = route1.GetRouteEnumerable(10).GetEnumerator();

            //List<Instruction> instructions = InstructionGenerator.Generate(route1, new OsmRoutingInterpreter());
//
            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute(route1);
            map.AddLayer(_routeLayer);

            View = mapView;

            mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));
            mapView.AddMarker(point1);
            mapView.AddMarker(point2);
            mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));
            mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));
//
//			//mapView.ZoomToMarkers();

            //GeoCoordinateBox box = new GeoCoordinateBox (new GeoCoordinate[] { point1, point2 });
//
            mapView.MapTapEvent += delegate(GeoCoordinate geoCoordinate)
            {
                //_routeTrackerAnimator.Track(box.GenerateRandomIn());

                //_mapView.AddMarker(geoCoordinate).Click += new EventHandler(MainActivity_Click);
                //mapViewAnimator.Stop();
                //mapViewAnimator.Start(geoCoordinate, 15, new TimeSpan(0, 0, 2));
            };

            RouteTracker routeTracker = new RouteTracker(route1, new OsmRoutingInterpreter());

            _routeTrackerAnimator = new RouteTrackerAnimator(mapView, routeTracker, 5);
//
//				Timer timer = new Timer (150);
//				timer.Elapsed += new ElapsedEventHandler (TimerHandler);
//				timer.Start ();
//
//			Task.Factory.StartNew (() => {
//				System.Threading.Thread.Sleep(200); // do something.
//				InvokeOnMainThread (() => {
//					mapView.ZoomToMarkers ();
//				});
//			});


            //
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes the View property.
        /// </summary>
        public override void LoadView()
        {
            base.LoadView();

            // initialize OsmSharp native hooks.
            Native.Initialize();

            // enable the loggging.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(new OsmSharp.iOS.UI.Log.ConsoleTraceListener());

            // initialize map.
            var map = new Map();
            // add a tile layer.
            //            map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));
            //            map.AddLayer(new LayerMBTile(SQLiteConnection.CreateFrom(
            //                Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.iOS.UI.Sample.kempen.mbtiles"), "map")));

            // add an online osm-data->mapCSS translation layer.
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            // add a pre-processed vector data file.
            var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "OsmSharp.iOS.UI.Sample.default.map");

            map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            //            var primitivesLayer = new LayerPrimitives(map.Projection);
            //            primitivesLayer.AddPoint(new GeoCoordinate(51.26371, 4.78601), 10,
            //                SimpleColor.FromKnownColor(KnownColor.Blue).Value);
            //            map.AddLayer(primitivesLayer);

            //			// define dummy from and to points.
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to   = new GeoCoordinate(51.267797, 4.801362);

            //
            //			// deserialize the pre-processed graph.
            //			var routingSerializer = new CHEdgeDataDataSourceSerializer(false);
            //			TagsCollectionBase metaData = null;
            //			var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
            //				"OsmSharp.iOS.UI.Sample.kempen-big.osm.pbf.routing");
            //			var graphDeserialized = routingSerializer.Deserialize(graphStream, out metaData, true);
            //
            //			// initialize router.
            //			_router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());
            //
            //			// resolve points.
            //			RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, from);
            //			RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, to);
            //
            //			// calculate route.
            //			Route route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            //			RouteTracker routeTracker = new RouteTracker(route, new OsmRoutingInterpreter());
            //			_enumerator = route.GetRouteEnumerable(10).GetEnumerator();
            //
            //			// add a router layer.
            //			_routeLayer = new LayerRoute(map.Projection);
            //			_routeLayer.AddRoute (route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
            //			map.AddLayer(_routeLayer);

            // define the mapview.
            _mapView = new MapView();
            //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
            _mapView.MapAllowTilt    = false;
            _mapView.Map             = map;
            _mapView.MapMaxZoomLevel = 19;
            _mapView.MapMinZoomLevel = 0;
            _mapView.MapTilt         = 0;
            _mapView.MapCenter       = new GeoCoordinate(51.26371, 4.78601);
            _mapView.MapZoom         = 18;
            _mapView.MapInitialized += _mapView_MapInitialized;

            // add markers.
            var marker        = _mapView.AddMarker(from);
            var popupTextView = new UITextView();

            popupTextView.Text            = "Hey, this is popup text!";
            popupTextView.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f);
            marker.AddPopup(popupTextView, 100, 100);
            marker                        = _mapView.AddMarker(to);
            popupTextView                 = new UITextView();
            popupTextView.Text            = "Hey, this is another popup text!";
            popupTextView.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f);
            marker.AddPopup(popupTextView, 100, 100);

            this.AddMarkers();

            // add center marker.
            _centerMarker = _mapView.AddMarker(_mapView.MapCenter);

            // create the route tracker animator.
            // _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17);

            //			// simulate a number of gps-location update along the calculated route.
            //			Timer timer = new Timer(250);
            //			timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            //			timer.Start();

            View = _mapView;
        }
Exemplo n.º 11
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement == null || e.OldElement != null)
            {
                return;
            }

            //e.NewElement就是承载的界面,这里就是PCL项目里面的MainPage
            //var mainPage = e.NewElement as TencentMapSamples;
            var mainPage = e.NewElement as Samples.Controls.TencentMap;

            //初始化mapView
            mapView = new MapView(this.Context);
            mapView.OnCreate(null);

            //初始化视图
            layout = new LinearLayout(this.Context);
            layout.AddView(mapView);
            this.AddView(layout);

            //这里可以比对以下我们的写法跟腾讯官网里Java写法的区别,可以看出Java里面的属性是set,get前缀,而在C#里面都被隐藏了,直接用C#惯用的属性写法来代替,而方法则还是同样的SetXXX(),GetXXX(),但是Java是camelCasing,C#用PascalCasing写法(博主非常喜欢C#写法,而很讨厌Java的写法 :-))。这些区别,都是Xamarin 里 绑定Java库的转换规则。

            #region TencentMap类
            //腾讯地图的设置是通过TencentMap类进行设置,可以控制地图的底图类型、显示范围、缩放级别、添加 / 删除marker和图形,此外对于地图的各种回调监听也是绑定到TencentMap。下面是TencentMap类的使用示例:

            //获取TencentMap实例
            TencentMap tencentMap = mapView.Map;
            //设置实时路况开启
            tencentMap.TrafficEnabled = true;
            //设置地图中心点
            tencentMap.SetCenter(new Com.Tencent.Mapsdk.Raster.Model.LatLng(30.605870, 104.068610));
            //设置缩放级别
            tencentMap.SetZoom(11);
            #endregion

            #region UiSettings类
            //UiSettings类用于设置地图的视图状态,如Logo位置设置、比例尺位置设置、地图手势开关等。下面是UiSettings类的使用示例:

            //获取UiSettings实例
            UiSettings uiSettings = mapView.UiSettings;
            //设置logo到屏幕底部中心
            uiSettings.SetLogoPosition(UiSettings.LogoPositionCenterBottom);
            //设置比例尺到屏幕右下角
            uiSettings.SetScaleViewPosition(UiSettings.ScaleviewPositionRightBottom);
            //启用缩放手势(更多的手势控制请参考开发手册)
            uiSettings.SetZoomGesturesEnabled(true);
            #endregion

            #region 使用marker
            //注意,这里要往resources/drawable/里添加一个red_location.png的图片
            var bitmap           = Resources.GetBitmap("red_location.png");
            BitmapDescriptor des = new BitmapDescriptor(bitmap);
            foreach (var item in mainPage.Options)
            {
                MarkerOptions options = new MarkerOptions();

                options.InvokeIcon(des);
                options.InvokeTitle(item.Title);
                options.Anchor(0.5f, 0.5f);
                options.InvokePosition(new LatLng(item.Lat, item.Lng));
                options.Draggable(true);
                Marker marker = mapView.AddMarker(options);
                marker.ShowInfoWindow();
            }

            #endregion
        }
Exemplo n.º 12
0
        public override void LoadView()
        {
            OsmSharp.Logging.Log.Enable ();
            //            OsmSharp.Logging.Log.RegisterListener(
            //                new OsmSharp.Android.UI.Log.LogTraceListener());
            base.LoadView ();

            // initialize a test-map.
            var map = new Map ();
            map.AddLayer (new LayerScene (Scene2D.Deserialize (
                Assembly.GetExecutingAssembly ().GetManifestResourceStream (
                    "OsmSharp.iOS.UI.Sample.kempen-big.osm.pbf.scene.layered"),
                        true)));

            // Perform any additional setup after loading the view, typically from a nib.
            MapView mapView = new MapView ();
            _mapView = mapView;
            //mapViewAnimator = new MapViewAnimator (mapView);
            mapView.Map = map;
            mapView.MapCenter = new GeoCoordinate(51.26371, 4.78601); // wechel
            //			mapView.MapTapEvent+= delegate(GeoCoordinate geoCoordinate) {
            //				mapView.AddMarker(geoCoordinate).TouchDown  += MapMarkerClicked;
            //			};

            mapView.MapMaxZoomLevel = 18;
            mapView.MapMinZoomLevel = 12;
            mapView.MapZoom = 16;
            mapView.MapTilt = 30;

            TagsCollectionBase metaData;
            var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.v2.CHEdgeDataDataSourceSerializer(false);
            var graphDeserialized = routingSerializer.Deserialize(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    "OsmSharp.iOS.UI.Sample.kempen-big.osm.pbf.routing"), out metaData, true);

            _router = Router.CreateCHFrom(
                graphDeserialized, new CHRouter(),
                new OsmRoutingInterpreter());

            var from = new GeoCoordinate(51.261203, 4.780760);
            var to = new GeoCoordinate(51.267797, 4.801362);

            RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, from);
            RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, to);
            Route route1 = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            _enumerator = route1.GetRouteEnumerable(10).GetEnumerator();

            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute (route1);
            map.AddLayer(_routeLayer);

            View = mapView;

            mapView.AddMarker(from);
            mapView.AddMarker(to);

            RouteTracker routeTracker = new RouteTracker(route1, new OsmRoutingInterpreter());
            _routeTrackerAnimator = new RouteTrackerAnimator(mapView, routeTracker, 5);

            //            Timer timer = new Timer (250);
            //            timer.Elapsed += new ElapsedEventHandler (TimerHandler);
            //            timer.Start ();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            OsmSharp.Logging.Log.Enable();

//			OsmSharp.IO.Output.OutputStreamHost.RegisterOutputStream (
//				new OsmSharp.Android.UI.IO.Output.ConsoleOutputStream ());

            // create the MapCSS image source.
            var imageSource = new MapCSSDictionaryImageSource();

            imageSource.Add("styles/default/parking.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.parking.png"));
            imageSource.Add("styles/default/bus.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.bus.png"));
            imageSource.Add("styles/default/postbox.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.postbox.png"));

//			// load mapcss style interpreter.
//			var mapCSSInterpreter = new MapCSSInterpreter(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.mapcss"),
//				imageSource);

            // initialize the data source.
            //var dataSource = new MemoryDataSource();
//			var source = new XmlOsmStreamReader(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm"));
//			var source = new PBFOsmStreamReader(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm.pbf"));
//			dataSource.PullFromSource(source);

            // initialize map.
            var map = new Map();

            //map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
//			map.AddLayer(new LayerScene(Scene2DSimple.Deserialize(
//							Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.osm.pbf.scene.simple"), true)));
            map.AddLayer(
                new LayerScene(
                    Scene2DLayered.Deserialize(
                        Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.wvl.map"), true)));

//			var routingSerializer = new V2RoutingDataSourceLiveEdgeSerializer(true);
//			var graphSerialized = routingSerializer.Deserialize(
//				//Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm.pbf.routing.3"));
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.pbf.routing.4"));
////
////			var graphLayer = new LayerDynamicGraphLiveEdge(graphSerialized, mapCSSInterpreter);
////			map.AddLayer(graphLayer);
//
//			// calculate route.
//			Router router = Router.CreateLiveFrom(
//				graphSerialized,
//				new OsmRoutingInterpreter());

            var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer(false);
            var graphDeserialized = routingSerializer.Deserialize(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.routing"), true);

            _router = Router.CreateCHFrom(
                graphDeserialized, new CHRouter(),
                new OsmRoutingInterpreter());
            GeoCoordinate point1       = new GeoCoordinate(51.158075, 2.961545);
            GeoCoordinate point2       = new GeoCoordinate(51.190503, 3.004793);
            RouterPoint   routerPoint1 = _router.Resolve(Vehicle.Car, point1);
            RouterPoint   routerPoint2 = _router.Resolve(Vehicle.Car, point2);
            Route         route1       = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            RouteTracker  routeTracker = new RouteTracker(route1, new OsmRoutingInterpreter());

            _enumerator = route1.GetRouteEnumerable(20).GetEnumerator();

            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute(route1, SimpleColor.FromKnownColor(KnownColor.Blue).Value);
            map.AddLayer(_routeLayer);

//			// create gpx layer.
//			LayerGpx gpxLayer = new LayerGpx(map.Projection);
//			gpxLayer.AddGpx(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.gpx"));
//			map.AddLayer(gpxLayer);

//			// set control properties.
//			var mapView = new MapView(this);
//			mapView.MapMaxZoomLevel = 20;
//			mapView.MapMinZoomLevel = 12;
//			//var mapView = new MapGLView (this);
//			mapView.Map = map;
//			//mapView.Center = new GeoCoordinate(51.158075, 2.961545); // gistel
//			//mapView.MapCenter = new GeoCoordinate (50.88672, 3.23899);
//			mapView.MapCenter = new GeoCoordinate(51.26337, 4.78739);
//			//mapView.Center = new GeoCoordinate(51.156803, 2.958887);
//			mapView.MapZoomLevel = 15;

//			var mapView = new OpenGLRenderer2D(
//				this, null);

//            _mapView = new MapView<MapGLView>(this, new MapGLView(this));

            _mapView = new MapView(this, new MapViewSurface(this));
            //_mapView = new MapView(this, new MapViewGLSurface(this));
            _mapView.Map = map;

            (_mapView as IMapView).AutoInvalidate = true;
            _mapView.MapMaxZoomLevel = 20;
            _mapView.MapMinZoomLevel = 12;
            _mapView.MapTilt         = 0;
            //var mapView = new MapGLView (this);
            _mapView.MapCenter = new GeoCoordinate(51.158075, 2.961545); // gistel
            //mapView.MapCenter = new GeoCoordinate (50.88672, 3.23899);
            //mapLayout.MapCenter = new GeoCoordinate(51.26337, 4.78739);
            //mapView.Center = new GeoCoordinate(51.156803, 2.958887);
            _mapView.MapZoom = 17;
            //MapViewAnimator mapViewAnimator = new MapViewAnimator(mapLayout);
            //_mapView.MapTapEvent += delegate(GeoCoordinate geoCoordinate)
            //{
            //    _mapView.ZoomToMarkers();
            //    //_mapView.AddMarker(geoCoordinate).Click += new EventHandler(MainActivity_Click);
            //    //mapViewAnimator.Stop();
            //    //mapViewAnimator.Start(geoCoordinate, 15, new TimeSpan(0, 0, 2));
            //};

            //Create the user interface in code
            var layout = new RelativeLayout(this);

            layout.AddView(_mapView);

            _mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            _mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));

            //_mapView.ZoomToMarkers();

            _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5);

            Timer timer = new Timer(250);

            timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            timer.Start();

            SetContentView(layout);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes the View property.
        /// </summary>
        public override void LoadView()
        {
            base.LoadView ();

            // enable the logggin.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(new OsmSharp.iOS.UI.Log.ConsoleTraceListener());

            // initialize map.
            var map = new Map();
            // add a tile layer.
            //map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));
            // add an online osm-data->mapCSS translation layer.
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            // add a pre-processed vector data file.
            var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "OsmSharp.iOS.UI.Sample.kempen-big.osm.pbf.scene.layered");
            map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            // define dummy from and to points.
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to = new GeoCoordinate(51.267797, 4.801362);

            // deserialize the pre-processed graph.
            var routingSerializer = new CHEdgeDataDataSourceSerializer(false);
            TagsCollectionBase metaData = null;
            var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "OsmSharp.iOS.UI.Sample.kempen-big.osm.pbf.routing");
            var graphDeserialized = routingSerializer.Deserialize(graphStream, out metaData, true);

            // initialize router.
            _router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());

            // resolve points.
            RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, from);
            RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, to);

            // calculate route.
            Route route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            RouteTracker routeTracker = new RouteTracker(route, new OsmRoutingInterpreter());
            _enumerator = route.GetRouteEnumerable(10).GetEnumerator();

            // add a router layer.
            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute (route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
            map.AddLayer(_routeLayer);

            // define the mapview.
            _mapView = new MapView();
            //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 20;
            _mapView.MapMinZoomLevel = 10;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(51.26371, 4.78601);
            _mapView.MapZoom = 18;

            // add markers.
            _mapView.AddMarker (from);
            _mapView.AddMarker (to);

            // create the route tracker animator.
            _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17);

            // simulate a number of gps-location update along the calculated route.
            Timer timer = new Timer(250);
            timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            timer.Start();

            View = _mapView;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // hide title bar.
            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            // initialize map.
            var map = new Map();
            map.AddLayer(new LayerMBTile(OsmSharp.Android.UI.Data.SQLite.SQLiteConnection.CreateFrom(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.kempen.mbtiles"), "map")));
            // add a tile layer.

            //var layer = new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png");
            //map.AddLayer(layer);
            //layer.IsVisible = false;
            //map.AddLayer(new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png"));
            //map.AddLayerGpx(Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.regression1.gpx"));
            //
            // add an on-line osm-data->mapCSS translation layer.
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            // add a preprocessed vector data file.
            //var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.default.map");
            //map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            //// define dummy from and to points.
            //var from = new GeoCoordinate(51.261203, 4.780760);
            //var to = new GeoCoordinate(51.267797, 4.801362);

            //// deserialize the preprocessed graph.
            //var routingSerializer = new CHEdgeDataDataSourceSerializer();
            //var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.kempen-big.osm.pbf.routing");
            //var graphDeserialized = routingSerializer.Deserialize(graphStream, true);

            //// initialize router.
            //_router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());

            //// resolve points.
            //var routerPoint1 = _router.Resolve(Vehicle.Car, from);
            //var routerPoint2 = _router.Resolve(Vehicle.Car, to);

            //// calculate route.
            //var route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);

            //// add a router layer.
            //_routeLayer = new LayerRoute(map.Projection);
            //_routeLayer.AddRoute(route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
            //map.AddLayer(_routeLayer);

            // define the mapview.
            _mapView = new MapView(this, new MapViewSurface(this));
            //_mapView = new MapView(this, new MapViewGLSurface(this));
            //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
            _mapView.MapTapEvent += _mapView_MapTapEvent;
            _mapView.Map = map;
            //_mapView.MapMaxZoomLevel = 20;
            //_mapView.MapMinZoomLevel = 10;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(51.261203, 4.780760);
            _mapView.MapZoom = 16;
            _mapView.MapAllowTilt = false;

            _mapView.MapTouchedUp += _mapView_MapTouchedUp;
            _mapView.MapTouched += _mapView_MapTouched;
            _mapView.MapTouchedDown += _mapView_MapTouchedDown;

            // AddMarkers();
            // AddControls();

            // initialize a text view to display routing instructions.
            _textView = new TextView(this);
            _textView.SetBackgroundColor(global::Android.Graphics.Color.White);
            _textView.SetTextColor(global::Android.Graphics.Color.Black);

            // add the mapview to the linear layout.
            var layout = new RelativeLayout(this);
            //layout.Orientation = Orientation.Vertical;
            //layout.AddView(_textView);
            layout.AddView(_mapView);

            // create the route tracker animator.
            //_routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17);

            // simulate a mapzoom change every 5 seconds.
            //Timer timer = new Timer(5000);
            //timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            //timer.Start();

            _centerMarker = _mapView.AddMarker(_mapView.MapCenter);

            _mapView.MapInitialized += _mapView_MapInitialized;

            SetContentView(layout);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // enable the logggin.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(new OsmSharp.Android.UI.Log.LogTraceListener());

            // initialize map.
            var map = new Map();
            // add a tile layer.
            //map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));
            // add an online osm-data->mapCSS translation layer.
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            // add a pre-processed vector data file.
            var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.default.map");

            map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            // define dummy from and to points.
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to   = new GeoCoordinate(51.267797, 4.801362);

            // deserialize the pre-processed graph.
            var routingSerializer       = new CHEdgeDataDataSourceSerializer(false);
            TagsCollectionBase metaData = null;
            var graphStream             = Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.kempen-big.osm.pbf.routing");
            var graphDeserialized       = routingSerializer.Deserialize(graphStream, out metaData, true);

            // initialize router.
            _router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());

            // resolve points.
            RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, from);
            RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, to);

            // calculate route.
            Route        route        = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            RouteTracker routeTracker = new RouteTracker(route, new OsmRoutingInterpreter());

            _enumerator = route.GetRouteEnumerable(10).GetEnumerator();

            // add a router layer.
            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute(route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
            map.AddLayer(_routeLayer);

            // define the mapview.
            _mapView = new MapView(this, new MapViewSurface(this));
            //_mapView = new MapView(this, new MapViewGLSurface(this));
            //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
            _mapView.Map             = map;
            _mapView.MapMaxZoomLevel = 20;
            _mapView.MapMinZoomLevel = 10;
            _mapView.MapTilt         = 0;
            _mapView.MapCenter       = new GeoCoordinate(51.26371, 4.78601);
            _mapView.MapZoom         = 18;

            // add markers.
            _mapView.AddMarker(from);
            _mapView.AddMarker(to);

            // initialize a text view to display routing instructions.
            _textView = new TextView(this);
            _textView.SetBackgroundColor(global::Android.Graphics.Color.White);
            _textView.SetTextColor(global::Android.Graphics.Color.Black);

            // add the mapview to the linear layout.
            var layout = new LinearLayout(this);

            layout.Orientation = Orientation.Vertical;
            layout.AddView(_textView);
            layout.AddView(_mapView);

            // create the route tracker animator.
            _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17);

            // simulate a number of gps-location update along the calculated route.
            Timer timer = new Timer(250);

            timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            timer.Start();

            SetContentView(layout);
        }
        public override void LoadView()
        {
            OsmSharp.Logging.Log.Enable ();

            base.LoadView ();

            // initialize a test-map.
            var map = new Map ();
            map.AddLayer (new LayerScene (Scene2DLayered.Deserialize (
                Assembly.GetExecutingAssembly ().GetManifestResourceStream ("OsmSharp.iOS.UI.Sample.wvl.map"),
                    true)));

            // Perform any additional setup after loading the view, typically from a nib.
            MapView mapView = new MapView ();
            _mapView = mapView;
            //mapViewAnimator = new MapViewAnimator (mapView);
            mapView.Map = map;
            mapView.MapCenter = new GeoCoordinate(51.158075, 2.961545); // gistel
            //			mapView.MapTapEvent+= delegate(GeoCoordinate geoCoordinate) {
            //				mapView.AddMarker(geoCoordinate).TouchDown  += MapMarkerClicked;
            //			};

            mapView.MapMaxZoomLevel = 18;
            mapView.MapMinZoomLevel = 12;
            mapView.MapZoom = 16;
            mapView.MapTilt = 30;

            var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer(false);
            var graphDeserialized = routingSerializer.Deserialize(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.iOS.UI.Sample.wvl.routing"), true);

            _router = Router.CreateCHFrom(
                graphDeserialized, new CHRouter(graphDeserialized),
                new OsmRoutingInterpreter());

            //			long before = DateTime.Now.Ticks;
            //
            //			var routeLocations = new GeoCoordinate[] {
            //				new GeoCoordinate (50.8247730, 2.7524706),
            //				new GeoCoordinate (50.8496394, 2.7301512),
            //				new GeoCoordinate (50.8927741, 2.6138545),
            //				new GeoCoordinate (50.8296363, 2.8869437)
            //			};
            //
            //			var routerPoints = new RouterPoint[routeLocations.Length];
            //			for (int idx = 0; idx < routeLocations.Length; idx++) {
            //				routerPoints [idx] = router.Resolve (Vehicle.Car, routeLocations [idx]);
            //
            //				mapView.AddMarker (routeLocations [idx]);
            //			}
            //			OsmSharp.Routing.TSP.RouterTSPWrapper<RouterTSPAEXGenetic> tspRouter = new OsmSharp.Routing.TSP.RouterTSPWrapper<RouterTSPAEXGenetic> (
            //				new RouterTSPAEXGenetic (10, 20), router);
            //
            //			Route route = tspRouter.CalculateTSP (Vehicle.Car, routerPoints);
            //
            //			long after = DateTime.Now.Ticks;
            //
            //			OsmSharp.Logging.Log.TraceEvent("OsmSharp.Android.UI.MapView", System.Diagnostics.TraceEventType.Information,"Routing & TSP in {0}ms",
            //			                                new TimeSpan (after - before).TotalMilliseconds);
            // 51.160477" lon="2.961497
            GeoCoordinate point1 = new GeoCoordinate(51.158075, 2.961545);
            GeoCoordinate point2 = new GeoCoordinate(51.190503, 3.004793);

            //GeoCoordinate point1 = new GeoCoordinate(51.159132, 2.958755);
            //GeoCoordinate point2 = new GeoCoordinate(51.160477, 2.961497);
            RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, point1);
            RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, point2);
            Route route1 = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            _enumerator = route1.GetRouteEnumerable(10).GetEnumerator();

            //List<Instruction> instructions = InstructionGenerator.Generate(route1, new OsmRoutingInterpreter());
            //
            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute (route1);
            map.AddLayer(_routeLayer);

            View = mapView;

            mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));
            mapView.AddMarker(point1);
            mapView.AddMarker(point2);
            mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));
            mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));
            //
            //			//mapView.ZoomToMarkers();

            //GeoCoordinateBox box = new GeoCoordinateBox (new GeoCoordinate[] { point1, point2 });
            //
            mapView.MapTapEvent += delegate(GeoCoordinate geoCoordinate)
            {
                //_routeTrackerAnimator.Track(box.GenerateRandomIn());

                //_mapView.AddMarker(geoCoordinate).Click += new EventHandler(MainActivity_Click);
                //mapViewAnimator.Stop();
                //mapViewAnimator.Start(geoCoordinate, 15, new TimeSpan(0, 0, 2));
            };

            RouteTracker routeTracker = new RouteTracker(route1, new OsmRoutingInterpreter());
            _routeTrackerAnimator = new RouteTrackerAnimator(mapView, routeTracker, 5);
            //
            //				Timer timer = new Timer (150);
            //				timer.Elapsed += new ElapsedEventHandler (TimerHandler);
            //				timer.Start ();
            //
            //			Task.Factory.StartNew (() => {
            //				System.Threading.Thread.Sleep(200); // do something.
            //				InvokeOnMainThread (() => {
            //					mapView.ZoomToMarkers ();
            //				});
            //			});

            //
        }
Exemplo n.º 18
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // hide title bar.
            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            // initialize map.
            var map = new Map();

            map.AddLayer(new LayerMBTile(OsmSharp.Android.UI.Data.SQLite.SQLiteConnection.CreateFrom(
                                             Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.kempen.mbtiles"), "map")));
            // add a tile layer.

            //var layer = new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png");
            //map.AddLayer(layer);
            //layer.IsVisible = false;
            //map.AddLayer(new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png"));
            //map.AddLayerGpx(Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.regression1.gpx"));
            //
            // add an on-line osm-data->mapCSS translation layer.
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            // add a preprocessed vector data file.
            //var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.default.map");
            //map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            //// define dummy from and to points.
            //var from = new GeoCoordinate(51.261203, 4.780760);
            //var to = new GeoCoordinate(51.267797, 4.801362);

            //// deserialize the preprocessed graph.
            //var routingSerializer = new CHEdgeDataDataSourceSerializer();
            //var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.kempen-big.osm.pbf.routing");
            //var graphDeserialized = routingSerializer.Deserialize(graphStream, true);

            //// initialize router.
            //_router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());

            //// resolve points.
            //var routerPoint1 = _router.Resolve(Vehicle.Car, from);
            //var routerPoint2 = _router.Resolve(Vehicle.Car, to);

            //// calculate route.
            //var route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);

            //// add a router layer.
            //_routeLayer = new LayerRoute(map.Projection);
            //_routeLayer.AddRoute(route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
            //map.AddLayer(_routeLayer);

            // define the mapview.
            _mapView = new MapView(this, new MapViewSurface(this));
            //_mapView = new MapView(this, new MapViewGLSurface(this));
            //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
            _mapView.MapTapEvent += _mapView_MapTapEvent;
            _mapView.Map          = map;
            //_mapView.MapMaxZoomLevel = 20;
            //_mapView.MapMinZoomLevel = 10;
            _mapView.MapTilt      = 0;
            _mapView.MapCenter    = new GeoCoordinate(51.261203, 4.780760);
            _mapView.MapZoom      = 16;
            _mapView.MapAllowTilt = false;

            _mapView.MapTouchedUp   += _mapView_MapTouchedUp;
            _mapView.MapTouched     += _mapView_MapTouched;
            _mapView.MapTouchedDown += _mapView_MapTouchedDown;

            // AddMarkers();
            // AddControls();

            // initialize a text view to display routing instructions.
            _textView = new TextView(this);
            _textView.SetBackgroundColor(global::Android.Graphics.Color.White);
            _textView.SetTextColor(global::Android.Graphics.Color.Black);

            // add the mapview to the linear layout.
            var layout = new RelativeLayout(this);

            //layout.Orientation = Orientation.Vertical;
            //layout.AddView(_textView);
            layout.AddView(_mapView);

            // create the route tracker animator.
            //_routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17);

            // simulate a mapzoom change every 5 seconds.
            //Timer timer = new Timer(5000);
            //timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            //timer.Start();

            _centerMarker = _mapView.AddMarker(_mapView.MapCenter);

            _mapView.MapInitialized += _mapView_MapInitialized;

            SetContentView(layout);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            OsmSharp.Logging.Log.Enable();

            //			OsmSharp.IO.Output.OutputStreamHost.RegisterOutputStream (
            //				new OsmSharp.Android.UI.IO.Output.ConsoleOutputStream ());

            // create the MapCSS image source.
            var imageSource = new MapCSSDictionaryImageSource();
            imageSource.Add("styles/default/parking.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.parking.png"));
            imageSource.Add("styles/default/bus.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.bus.png"));
            imageSource.Add("styles/default/postbox.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.postbox.png"));

            //			// load mapcss style interpreter.
            //			var mapCSSInterpreter = new MapCSSInterpreter(
            //				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.mapcss"),
            //				imageSource);

            // initialize the data source.
            //var dataSource = new MemoryDataSource();
            //			var source = new XmlOsmStreamReader(
            //				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm"));
            //			var source = new PBFOsmStreamReader(
            //				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm.pbf"));
            //			dataSource.PullFromSource(source);

            // initialize map.
            var map = new Map();
            //map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            //			map.AddLayer(new LayerScene(Scene2DSimple.Deserialize(
            //							Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.osm.pbf.scene.simple"), true)));
            map.AddLayer(
                new LayerScene(
                Scene2DLayered.Deserialize(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.wvl.map"), true)));

            //			var routingSerializer = new V2RoutingDataSourceLiveEdgeSerializer(true);
            //			var graphSerialized = routingSerializer.Deserialize(
            //				//Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm.pbf.routing.3"));
            //				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.pbf.routing.4"));
            ////
            ////			var graphLayer = new LayerDynamicGraphLiveEdge(graphSerialized, mapCSSInterpreter);
            ////			map.AddLayer(graphLayer);
            //
            //			// calculate route.
            //			Router router = Router.CreateLiveFrom(
            //				graphSerialized,
            //				new OsmRoutingInterpreter());

            var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer(false);
            var graphDeserialized = routingSerializer.Deserialize(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.routing"), true);

            _router = Router.CreateCHFrom(
                graphDeserialized, new CHRouter(),
                new OsmRoutingInterpreter());
            GeoCoordinate point1 = new GeoCoordinate(51.158075, 2.961545);
            GeoCoordinate point2 = new GeoCoordinate(51.190503, 3.004793);
            RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, point1);
            RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, point2);
            Route route1 = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            RouteTracker routeTracker = new RouteTracker(route1, new OsmRoutingInterpreter());
            _enumerator = route1.GetRouteEnumerable(20).GetEnumerator();

            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute (route1, SimpleColor.FromKnownColor(KnownColor.Blue).Value);
            map.AddLayer(_routeLayer);

            //			// create gpx layer.
            //			LayerGpx gpxLayer = new LayerGpx(map.Projection);
            //			gpxLayer.AddGpx(
            //				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.gpx"));
            //			map.AddLayer(gpxLayer);

            //			// set control properties.
            //			var mapView = new MapView(this);
            //			mapView.MapMaxZoomLevel = 20;
            //			mapView.MapMinZoomLevel = 12;
            //			//var mapView = new MapGLView (this);
            //			mapView.Map = map;
            //			//mapView.Center = new GeoCoordinate(51.158075, 2.961545); // gistel
            //			//mapView.MapCenter = new GeoCoordinate (50.88672, 3.23899);
            //			mapView.MapCenter = new GeoCoordinate(51.26337, 4.78739);
            //			//mapView.Center = new GeoCoordinate(51.156803, 2.958887);
            //			mapView.MapZoomLevel = 15;

            //			var mapView = new OpenGLRenderer2D(
            //				this, null);

            //            _mapView = new MapView<MapGLView>(this, new MapGLView(this));

            _mapView = new MapView(this, new MapViewSurface(this));
            //_mapView = new MapView(this, new MapViewGLSurface(this));
            _mapView.Map = map;

            (_mapView as IMapView).AutoInvalidate = true;
            _mapView.MapMaxZoomLevel = 20;
            _mapView.MapMinZoomLevel = 12;
            _mapView.MapTilt = 0;
            //var mapView = new MapGLView (this);
            _mapView.MapCenter = new GeoCoordinate(51.158075, 2.961545); // gistel
            //mapView.MapCenter = new GeoCoordinate (50.88672, 3.23899);
            //mapLayout.MapCenter = new GeoCoordinate(51.26337, 4.78739);
            //mapView.Center = new GeoCoordinate(51.156803, 2.958887);
            _mapView.MapZoom = 17;
            //MapViewAnimator mapViewAnimator = new MapViewAnimator(mapLayout);
            //_mapView.MapTapEvent += delegate(GeoCoordinate geoCoordinate)
            //{
            //    _mapView.ZoomToMarkers();
            //    //_mapView.AddMarker(geoCoordinate).Click += new EventHandler(MainActivity_Click);
            //    //mapViewAnimator.Stop();
            //    //mapViewAnimator.Start(geoCoordinate, 15, new TimeSpan(0, 0, 2));
            //};

            //Create the user interface in code
            var layout = new RelativeLayout (this);
            layout.AddView(_mapView);

            _mapView.AddMarker(new GeoCoordinate(51.1612, 2.9795));
            _mapView.AddMarker(new GeoCoordinate(51.1447, 2.9483));

            //_mapView.ZoomToMarkers();

            _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5);

            Timer timer = new Timer(250);
            timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            timer.Start();

            SetContentView (layout);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // enable the logggin.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(new OsmSharp.Android.UI.Log.LogTraceListener());

            // initialize map.
            var map = new Map();
            // add a tile layer.
            //map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));
            // add an online osm-data->mapCSS translation layer.
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            // add a pre-processed vector data file.
            var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.kempen-big.osm.pbf.scene.layered");
            map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            // define dummy from and to points.
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to = new GeoCoordinate(51.267797, 4.801362);

            // deserialize the pre-processed graph.
            var routingSerializer = new CHEdgeDataDataSourceSerializer(false);
            TagsCollectionBase metaData = null;
            var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.kempen-big.osm.pbf.routing");
            var graphDeserialized = routingSerializer.Deserialize(graphStream, out metaData, true);

            // initialize router.
            _router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());

            // resolve points.
            RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, from);
            RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, to);

            // calculate route.
            Route route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            RouteTracker routeTracker = new RouteTracker(route, new OsmRoutingInterpreter());
            _enumerator = route.GetRouteEnumerable(10).GetEnumerator();

            // add a router layer.
            _routeLayer = new LayerRoute(map.Projection);
            _routeLayer.AddRoute (route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
            map.AddLayer(_routeLayer);

            // define the mapview.
            _mapView = new MapView(this, new MapViewSurface(this));
            //_mapView = new MapView(this, new MapViewGLSurface(this));
            //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
            (_mapView as IMapView).AutoInvalidate = true;
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 20;
            _mapView.MapMinZoomLevel = 10;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(51.26371, 4.78601);
            _mapView.MapZoom = 18;

            // add markers.
            _mapView.AddMarker (from);
            _mapView.AddMarker (to);

            // initialize a text view to display routing instructions.
            _textView = new TextView(this);
            _textView.SetBackgroundColor(global::Android.Graphics.Color.White);
            _textView.SetTextColor(global::Android.Graphics.Color.Black);

            // add the mapview to the linear layout.
            var layout = new LinearLayout(this);
            layout.Orientation = Orientation.Vertical;
            layout.AddView(_textView);
            layout.AddView(_mapView);

            // create the route tracker animator.
            _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 18);

            // simulate a number of gps-location update along the calculated route.
            Timer timer = new Timer(500);
            timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            timer.Start();

            SetContentView (layout);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Initializes the View property.
        /// </summary>
        public override void LoadView()
        {
            base.LoadView ();

            // initialize OsmSharp native hooks.
            Native.Initialize();

            // enable the loggging.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(new OsmSharp.iOS.UI.Log.ConsoleTraceListener());

            // initialize map.
            var map = new Map();
            // add a tile layer.
            map.AddLayer(new LayerTile(@"http://192.168.43.155:1234/default/{0}/{1}/{2}.png"));
            //            map.AddLayer(new LayerMBTile(SQLiteConnection.CreateFrom(
            //                Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.iOS.UI.Sample.kempen.mbtiles"), "map")));

            // add an online osm-data->mapCSS translation layer.
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
            // add a pre-processed vector data file.
            //			var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
            //				"OsmSharp.iOS.UI.Sample.default.map");
            //			map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            //            var primitivesLayer = new LayerPrimitives(map.Projection);
            //            primitivesLayer.AddPoint(new GeoCoordinate(51.26371, 4.78601), 10,
            //                SimpleColor.FromKnownColor(KnownColor.Blue).Value);
            //            map.AddLayer(primitivesLayer);

            //			// define dummy from and to points.
            var from = new GeoCoordinate(51.261203, 4.780760);
            var to = new GeoCoordinate(51.267797, 4.801362);
            //
            //			// deserialize the pre-processed graph.
            //			var routingSerializer = new CHEdgeDataDataSourceSerializer(false);
            //			TagsCollectionBase metaData = null;
            //			var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
            //				"OsmSharp.iOS.UI.Sample.kempen-big.osm.pbf.routing");
            //			var graphDeserialized = routingSerializer.Deserialize(graphStream, out metaData, true);
            //
            //			// initialize router.
            //			_router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());
            //
            //			// resolve points.
            //			RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, from);
            //			RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, to);
            //
            //			// calculate route.
            //			Route route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
            //			RouteTracker routeTracker = new RouteTracker(route, new OsmRoutingInterpreter());
            //			_enumerator = route.GetRouteEnumerable(10).GetEnumerator();
            //
            //			// add a router layer.
            //			_routeLayer = new LayerRoute(map.Projection);
            //			_routeLayer.AddRoute (route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
            //			map.AddLayer(_routeLayer);

            // define the mapview.
            _mapView = new MapView();
            //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
            _mapView.MapAllowTilt = false;
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 19;
            _mapView.MapMinZoomLevel = 0;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(51.2633, 4.7853);
            _mapView.MapZoom = 18;
            _mapView.MapInitialized += _mapView_MapInitialized;

            // add markers.
            var marker = _mapView.AddMarker (from);
            var popupTextView = new UITextView();
            popupTextView.Text = "Hey, this is popup text!";
            popupTextView.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f);
            marker.AddPopup(popupTextView, 100, 100);
            marker = _mapView.AddMarker (to);
            popupTextView = new UITextView();
            popupTextView.Text = "Hey, this is another popup text!";
            popupTextView.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f);
            marker.AddPopup(popupTextView, 100, 100);

            this.AddMarkers();

            // add center marker.
            _centerMarker = _mapView.AddMarker(_mapView.MapCenter);

            // create the route tracker animator.
            // _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17);

            //			// simulate a number of gps-location update along the calculated route.
            //			Timer timer = new Timer(250);
            //			timer.Elapsed += new ElapsedEventHandler(TimerHandler);
            //			timer.Start();

            View = _mapView;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

//			OsmSharp.IO.Output.OutputStreamHost.RegisterOutputStream (
//				new OsmSharp.Android.UI.IO.Output.ConsoleOutputStream ());

            // create the MapCSS image source.
            var imageSource = new MapCSSDictionaryImageSource();

            imageSource.Add("styles/default/parking.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.parking.png"));
            imageSource.Add("styles/default/bus.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.bus.png"));
            imageSource.Add("styles/default/postbox.png",
                            Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.images.postbox.png"));

//			// load mapcss style interpreter.
//			var mapCSSInterpreter = new MapCSSInterpreter(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.mapcss"),
//				imageSource);

            // initialize the data source.
            //var dataSource = new MemoryDataSource();
//			var source = new XmlOsmStreamReader(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm"));
//			var source = new PBFOsmStreamReader(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm.pbf"));
//			dataSource.PullFromSource(source);

            // initialize map.
            var map = new Map();

            //map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));
            //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
//			map.AddLayer(new LayerScene(Scene2DSimple.Deserialize(
//							Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.osm.pbf.scene.simple"), true)));
            map.AddLayer(
                new LayerScene(
                    Scene2DLayered.Deserialize(
                        Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.wvl.map"), true)));

//			var routingSerializer = new V2RoutingDataSourceLiveEdgeSerializer(true);
//			var graphSerialized = routingSerializer.Deserialize(
//				//Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.osm.pbf.routing.3"));
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.pbf.routing.4"));
////
////			var graphLayer = new LayerDynamicGraphLiveEdge(graphSerialized, mapCSSInterpreter);
////			map.AddLayer(graphLayer);
//
//			// calculate route.
//			Router router = Router.CreateLiveFrom(
//				graphSerialized,
//				new OsmRoutingInterpreter());

//			var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer(false);
//			var graphDeserialized = routingSerializer.Deserialize(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.wvl.osm.pbf.routing.ch"), true);
////
//			_router = Router.CreateCHFrom(
//				graphDeserialized, new CHRouter(graphDeserialized),
//				new OsmRoutingInterpreter());

//
//			//GeoCoordinate point1 = new GeoCoordinate(51.158075, 2.961545);
//			//GeoCoordinate point2 = new GeoCoordinate(51.190503, 3.004793);
//			//GeoCoordinate point3 = new GeoCoordinate(51.175967, 2.93733);
//			GeoCoordinate point1 = new GeoCoordinate (50.885726, 3.253426);
//			//GeoCoordinate point2 = new GeoCoordinate (50.88602, 3.218149);
//			GeoCoordinate point2 = new GeoCoordinate (51.1515, 2.9563);
//			GeoCoordinate point3 = new GeoCoordinate(51.34643, 3.28837);
//
//			OsmSharpRoute route1 = router.Calculate(Vehicle.Car,
//			                                       router.Resolve(Vehicle.Car, point1),
//			                                       router.Resolve(Vehicle.Car, point2));
//
//			OsmSharpRoute route2 = router.Calculate(Vehicle.Car,
//			                                       router.Resolve(Vehicle.Car, point1),
//			                                       router.Resolve(Vehicle.Car, point3));
//
//			OsmSharpRoute route3 = router.Calculate(Vehicle.Car,
//			                                        router.Resolve(Vehicle.Car, point2),
//			                                        router.Resolve(Vehicle.Car, point3));
////
////			OsmSharpRoute route = router.Calculate(Vehicle.Car,
////			                                       router.Resolve(Vehicle.Car, new GeoCoordinate(51.15136, 3.19462)),
////			                                       router.Resolve(Vehicle.Car, new GeoCoordinate(51.075023, 3.096632)));
//////			route = router.Calculate(Vehicle.Car,
//////			                         router.Resolve(Vehicle.Car, new GeoCoordinate(51.075023, 3.096632)),
//////			                         router.Resolve(Vehicle.Car, new GeoCoordinate(51.15136, 3.19462)));
////			route = router.Calculate(Vehicle.Car,
////			                         router.Resolve(Vehicle.Car, new GeoCoordinate(51.15136, 3.19462)),
////			                         router.Resolve(Vehicle.Car, new GeoCoordinate(51.075023, 3.096632)));
            _routeLayer = new LayerOsmSharpRoute(map.Projection);
//			osmSharpLayer.AddRoute (route1, SimpleColor.FromKnownColor(KnownColor.Blue).Value);
//			osmSharpLayer.AddRoute (route2, SimpleColor.FromKnownColor(KnownColor.Red).Value);
//			osmSharpLayer.AddRoute (route3, SimpleColor.FromKnownColor(KnownColor.YellowGreen).Value);
            map.AddLayer(_routeLayer);

//			// create gpx layer.
//			LayerGpx gpxLayer = new LayerGpx(map.Projection);
//			gpxLayer.AddGpx(
//				Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.test.gpx"));
//			map.AddLayer(gpxLayer);

//			// set control properties.
//			var mapView = new MapView(this);
//			mapView.MapMaxZoomLevel = 20;
//			mapView.MapMinZoomLevel = 12;
//			//var mapView = new MapGLView (this);
//			mapView.Map = map;
//			//mapView.Center = new GeoCoordinate(51.158075, 2.961545); // gistel
//			//mapView.MapCenter = new GeoCoordinate (50.88672, 3.23899);
//			mapView.MapCenter = new GeoCoordinate(51.26337, 4.78739);
//			//mapView.Center = new GeoCoordinate(51.156803, 2.958887);
//			mapView.MapZoomLevel = 15;

//			var mapView = new OpenGLRenderer2D(
//				this, null);

            //var mapGLView = new MapGLView(this);

            var mapLayout = new MapView(this);

            mapLayout.Map = map;

            mapLayout.MapMaxZoomLevel = 20;
            mapLayout.MapMinZoomLevel = 12;
            //var mapView = new MapGLView (this);
            mapLayout.MapCenter = new GeoCoordinate(51.158075, 2.961545);             // gistel
            //mapView.MapCenter = new GeoCoordinate (50.88672, 3.23899);
            //mapLayout.MapCenter = new GeoCoordinate(51.26337, 4.78739);
            //mapView.Center = new GeoCoordinate(51.156803, 2.958887);
            mapLayout.MapZoomLevel = 15;
            mapLayout.MapTapEvent += delegate(GeoCoordinate geoCoordinate) {
                mapLayout.AddMarker(geoCoordinate).Click += new EventHandler(MapMarkerClicked);
            };

            //Create the user interface in code
            var layout = new RelativeLayout(this);

            //layout.Orientation = Orientation.Vertical;

            //layout.AddView(mapGLView);
            layout.AddView(mapLayout);

//			mapLayout.AddMarker (new GeoCoordinate (51.26337, 4.78739)).Click += new EventHandler (MapMarkerClicked);
//			mapLayout.AddMarker (new GeoCoordinate (51.26785, 4.78025)).Click += new EventHandler (MapMarkerClicked);

            SetContentView(layout);
        }