public byte[] RenderMapAsByteArray(IViewport viewport, Map map) { Image image = RenderMapAsImage(viewport, map); var memoryStream = new MemoryStream(); image.Save(memoryStream, ImageFormat.Bmp); return memoryStream.ToArray(); }
public static void Render(Graphics graphics, IViewport viewport, Map map, AbortRenderDelegate abortRender) { foreach (var layer in map.Layers) { if (layer.Enabled && layer.MinVisible <= viewport.Resolution && layer.MaxVisible >= viewport.Resolution) { if (layer is LabelLayer) { //!!!GdiLabelRenderer.Render(graphics, view, layer as LabelLayer); } else if (layer is ITileLayer) { var tileLayer = (layer as ITileLayer); GdiTileRenderer.Render(graphics, tileLayer.Schema, viewport, tileLayer.MemoryCache); } else { RenderLayer(graphics, viewport, layer, abortRender); } } if (abortRender != null && abortRender()) return; } }
public MapsUiView() { Map = new Mapsui.Map { BackColor = Color.White, Home = n => n.NavigateTo(SphericalMercator.FromLonLat(52.22002, 4.55835), 0.2) }; IsMyLocationButtonVisible = false; IsNorthingButtonVisible = false; IsZoomButtonVisible = false; MyLocationEnabled = false; CancellationTokenSource cancelToken = null; TouchStarted += (sender, args) => _isPanning = true; TouchEnded += async(sender, args) => { cancelToken?.Cancel(); cancelToken = new CancellationTokenSource(); try { await Task.Delay(2000, cancelToken.Token); _isPanning = false; } catch (OperationCanceledException) {} }; Navigator = new AnimatedNavigatorWithRotation(Map, (IViewport)Viewport); }
void FillLayerList(Map map) { var random = new Random(DateTime.Now.Second); bool firstButton = true; foreach (ILayer layer in map.Layers) { if (layer is GroupTileLayer) { foreach (ILayer subLayer in (layer as GroupTileLayer).Layers) { var checkBox = new CheckBox(); checkBox.Margin = new Thickness(10, 0, 0, 0); checkBox.Click += checkBox_Click; checkBox.Name = random.Next().ToString(CultureInfo.InvariantCulture); //subLayer.LayerName; checkBox.Content = subLayer.LayerName; checkBox.Tag = subLayer; checkBox.Margin = new Thickness(4); checkBox.FontSize = 12; checkBox.IsChecked = true; layerList.Children.Add(checkBox); if (firstButton) { checkBox.IsChecked = true; firstButton = false; } } } } }
/// <summary> /// Create the map /// </summary> private void ConfigureMap() { this.Map = new Mapsui.Map { CRS = "EPSG:3857", Transformation = new MinimalTransformation(), }; }
public static Image RenderMapAsImage(IViewport viewport, Map map) { if ((viewport.Width <= 0) || (viewport.Height <= 0)) throw new Exception("The view's width or heigh is 0"); var image = new System.Drawing.Bitmap((int)viewport.Width, (int)viewport.Height); var graphics = Graphics.FromImage(image); #if !PocketPC graphics.PageUnit = GraphicsUnit.Pixel; #endif Render(graphics, viewport, map, null); return image; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.fragment_map, container, false); Log.Debug($"Create mapControl"); mapControl = view.FindViewById <MapControl>(Resource.Id.mapcontrol); map = new Mapsui.Map { CRS = "EPSG:3857", //https://epsg.io/3857 Transformation = new MinimalTransformation(), }; mapControl.Map = map; Log.Debug($"Cache downloaded tiles"); var tileSource = TileCache.GetOSMBasemap(MainActivity.rootPath + "/CacheDB.mbtiles"); var tileLayer = new TileLayer(tileSource) { Name = "OSM", }; map.Layers.Add(tileLayer); Log.Debug($"Import all offline maps"); OfflineMaps.LoadAllOfflineMaps(); Log.Debug($"Add scalebar"); map.Widgets.Add(new ScaleBarWidget(map) { MaxWidth = 300, ShowEnvelop = true, Font = new Font { FontFamily = "sans serif", Size = 20 }, TickLength = 15, TextColor = new Color(0, 0, 0, 255), Halo = new Color(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, TextAlignment = Alignment.Left, ScaleBarMode = ScaleBarMode.Both, UnitConverter = MetricUnitConverter.Instance, SecondaryUnitConverter = NauticalUnitConverter.Instance, MarginX = 10, MarginY = 20, }); Log.Debug($"Set Zoom"); mapControl.Navigator.ZoomTo(PrefsActivity.MaxZoom); return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); var mapControl = FindViewById <MapControl>(Resource.Id.mapcontrol); var map = new Mapsui.Map(); mapControl.Map = new CreateMapLocations(this).CreateMap(); //mapControl.Map = map; mapControl.Map.Info += StopInfo; }
private Map CreateMap() { var map = new Map(); var osmLayer = new TileLayer(new OsmTileSource()) { LayerName = "OSM" }; map.Layers.Add(osmLayer); var pointLayer = PointLayerSample.CreateRandomPointLayer(map.Envelope, 600); var bitmapData = System.Reflection.Assembly.GetExecutingAssembly() .GetManifestResourceStream("Mapsui.Silverlight.UI.Images.btnBbox.png"); var symbolStyle = new SymbolStyle { Symbol = new Bitmap { Data = bitmapData } }; pointLayer.Styles.Add(symbolStyle); map.Layers.Add(pointLayer); return map; }
public MapControl() { InitializeComponent(); Map = new Map(); //this.viewport.Resolution = 19; #if DEBUG ShowStatistics = true; #else ShowStatistics = false; #endif MouseInfoOverLayers = new List<ILayer>(); MouseInfoDownLayers = new List<ILayer>(); Loaded += MapControl_Loaded; KeyDown += MapControl_KeyDown; KeyUp += MapControl_KeyUp; MouseLeftButtonDown += MapControl_MouseLeftButtonDown; MouseLeftButtonUp += MapControl_MouseLeftButtonUp; MouseMove += MapControl_MouseMove; MouseLeave += MapControl_MouseLeave; MouseWheel += MapControl_MouseWheel; SizeChanged += MapControlSizeChanged; CompositionTarget.Rendering += CompositionTarget_Rendering; renderer = new MapRenderer(); canvas.Children.Add(renderCanvas); #if !SILVERLIGHT Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; #endif fps.SetBinding(TextBlock.TextProperty, new Binding("Fps")); fps.DataContext = FpsCounter; }
private void MainPageLoaded(object sender, RoutedEventArgs e) { //Land Events landRequest.LandReceived += LandChanged; landRequest.LandsReceived += landRequest_LandsReceived; landRequest.VerifiedLandCodesReceived += landRequest_VerifiedLandCodesReceived; landRequest.CheckPercentageReceived += landRequest_CheckPercentageReceived; landRequest.PresicionPercentageReceived += landRequest_PresicionPercentageReceived; //Jaguar, DailyMessage, Contest Events jaguarRequests.PositionReceived += jaguarRequests_PositionReceived; popupMessageRequests.MessageReceived += popupMessageRequests_MessageReceived; contestRequests.ContestReceived += contestRequests_ContestReceived; //Tutorial Events StoryBoardTutorialUI0.Completed += StoryBoardTutorialUI0_Completed; //termino de mostrar el mapa y los textos StoryBoardLoadingTutorialUI0.Completed += StoryBoardLoadingTutorialUI0_Completed; //termino de mostrar el mapa y el loading para cargarlos StoryBoardTutorialUI1.Completed += StoryBoardTutorialUI1_Completed; //termino de presentarle la parcela y dejo el boton [mi parcela] titilando //Layers Events this.OpacitiesStoryBoard.Completed += OpacitiesStoryBoard_Completed; this.layerList.ChangingOpacity += layerList_ChangingOpacity; this.layerList.HexLayerVisibilityChanged += layerList_HexLayerVisibilityChanged; this.layerList.ArgentineLawLayerLayerVisibilityChanged += layerList_ArgentineLawLayerLayerVisibilityChanged; this.layerList.ArgentineLawLoaded += layerList_ArgentineLawLoaded; this.layerList.ArgentineLawLoading += layerList_ArgentineLawLoading; this.ChangeOpacityStoryBoard.Completed += ChangeOpacityStoryBoard_Completed; HtmlPage.RegisterScriptableObject("Credentials", this); //Create and set map var map = new Map(); mapControl.Map = map; //Initialize the singleton Current.Instance.MapControl = mapControl; //Pass the LayerCollection used on the map to the helper, this is used to distinguish base, normal, ... layers layerHelper = new LayerHelper(map.Layers); //Activate GeoHexCode Search only if admin if (Current.Instance.Earthwatcher.Role == Role.Admin) { this.TestGeoHexTextBox.Visibility = Visibility.Visible; } Current.Instance.LayerHelper = layerHelper; //Load the preset layers LayerInitialization.Initialize(layerHelper); layerList.SetLayerHelper(layerHelper); //Report Window First And Unic Inicialization reportWindow = new ReportWindow(new Land(), Current.Instance.Earthwatcher); reportWindow.ReportWindowClosed += reportWindow_ReportWindowClosed; reportWindow.CollectionCompleted += reportWindow_CollectionCompleted; reportWindow.ReportWindowDemand += reportWindow_ReportWindowDemand; reportWindow.Shared += reportWindow_Shared; reportWindow.ReportWindowConfirmationEnded += reportWindow_ReportWindowConfirmationEnded; reportWindow.ReportWindowLandStatusChanged += reportWindow_ReportWindowLandStatusChanged; landInfoWrapper.Children.Add(reportWindow); //Get PlayingRegion Object regionRequest.GetById(Current.Instance.Earthwatcher.PlayingRegion); //GetShareTexts for region and language customShareTextRequest.GetByRegionIdAndLanguage(Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.Earthwatcher.Language); MapControl_zoomFinished(null, null); MapControl_zoomStarted(null, null); scoreRequest.GetByUser(Current.Instance.Earthwatcher.Id); }
public Lobby() { hours = 0; minutes = 0; seconds = 12; InitializeComponent(); var map = new Mapsui.Map { CRS = "EPSG:3857", Transformation = new MinimalTransformation() }; var tileLayer = new HttpTileSource(new GlobalSphericalMercator(), "https://api.maptiler.com/maps/hybrid/{z}/{x}/{y}.jpg?key=UNzmzzs5vM5fHNT7gBDM", new[] { "a", "b", "c" }, name: "OpenStreetMap", attribution: OpenStreetMapAttribution); map.Layers.Add(new TileLayer(tileLayer)); map.Home = n => n.NavigateTo(SphericalMercator.FromLonLat(-2.32624, 51.37795), mapView.Map.Resolutions[14]); mapView.IsMyLocationButtonVisible = false; mapView.IsNorthingButtonVisible = false; mapView.Map = map; mapView.Drawables.Add(CreatePolygon()); Device.StartTimer(TimeSpan.FromSeconds(1), () => { if (seconds == 0 && hours == 0 && minutes == 0) { StartGame(); } if (seconds == 0) { seconds = 60; minutes -= 1; } ; if (minutes == -1) { minutes = 59; hours -= 1; } ; seconds -= 1; string labelText; labelText = hours.ToString(); labelText += ":"; if (minutes < 10) { labelText += "0" + minutes.ToString(); } else { labelText += minutes.ToString(); } labelText += ":"; if (seconds < 10) { labelText += "0" + seconds.ToString(); } else { labelText += seconds.ToString(); } Device.BeginInvokeOnMainThread(() => { TimerLabel.Text = labelText; }); return(true); // True = Repeat again, False = Stop the timer }); }
private void MainPageLoaded(object sender, RoutedEventArgs e) { landRequest.LandReceived += LandChanged; landRequest.LandsReceived += landRequest_LandsReceived; landRequest.VerifiedLandCodesReceived += landRequest_VerifiedLandCodesReceived; jaguarRequests.PositionReceived += jaguarRequests_PositionReceived; popupMessageRequests.MessageReceived += popupMessageRequests_MessageReceived; contestRequests.ContestReceived += contestRequests_ContestReceived; Tutorial0StoryBoard.Completed += Tutorial0StoryBoard_Completed; Tutorial0LoadingStoryBoard.Completed += Tutorial0LoadingStoryBoard_Completed; Tutorial1StoryBoard.Completed += Tutorial1StoryBoard_Completed; Tutorial3StoryBoard.Completed += Tutorial3StoryBoard_Completed; this.OpacitiesStoryBoard.Completed += OpacitiesStoryBoard_Completed; this.layerList.ChangingOpacity += layerList_ChangingOpacity; this.layerList.HexLayerVisibilityChanged += layerList_HexLayerVisibilityChanged; this.layerList.ArgentineLawLayerLayerVisibilityChanged += layerList_ArgentineLawLayerLayerVisibilityChanged; this.layerList.ArgentineLawLoaded += layerList_ArgentineLawLoaded; this.layerList.ArgentineLawLoading += layerList_ArgentineLawLoading; this.ChangeOpacityStoryBoard.Completed += ChangeOpacityStoryBoard_Completed; HtmlPage.RegisterScriptableObject("Credentials", this); //SizeChanged += MainPageSizeChanged; //Create and set map var map = new Map(); mapControl.Map = map; //Initialize the singleton Current.Instance.MapControl = mapControl; //Pass the LayerCollection used on the map to the helper, this is used to distinguish base, normal, ... layers layerHelper = new LayerHelper(map.Layers); Current.Instance.LayerHelper = layerHelper; //Load the preset layers LayerInitialization.Initialize(layerHelper); layerList.SetLayerHelper(layerHelper); hexagonInfo = new HexagonInfo(); hexagonInfo.ReportWindowClosed += hexagonInfo_ReportWindowClosed; hexagonInfo.CollectionCompleted += hexagonInfo_CollectionCompleted; hexagonInfo.ReportWindowDemand += hexagonInfo_ReportWindowDemand; hexagonInfo.Shared += hexagonInfo_Shared; hexagonInfo.ReportWindowConfirmationEnded += hexagonInfo_ReportWindowConfirmationEnded; hexagonInfo.ReportWindowLandStatusChanged += hexagonInfo_ReportWindowLandStatusChanged; landInfoWrapper.Children.Add(hexagonInfo); //var flagLayer = Current.Instance.LayerHelper.FindLayer(Constants.flagLayerName) as FlagLayer; //if (flagLayer != null) flagLayer.RequestFlags(); MapControl_zoomFinished(null, null); MapControl_zoomStarted(null, null); scoreRequest.GetByUser(Current.Instance.Earthwatcher.Id); }
public AnimatedNavigatorWithRotation(Mapsui.Map map, IViewport viewport) { _map = map; _viewport = viewport; }
private void MainPageLoaded(object sender, RoutedEventArgs e) { landRequest.LandReceived += LandChanged; Tutorial0StoryBoard.Completed += Tutorial0StoryBoard_Completed; Tutorial3StoryBoard.Completed += Tutorial3StoryBoard_Completed; Tutorial25StoryBoard.Completed += Tutorial25StoryBoard_Completed; this.OpacitiesStoryBoard.Completed += OpacitiesStoryBoard_Completed; this.layerList.AddingLayer += layerList_AddingLayer; this.layerList.LayerAdded += layerList_LayerAdded; HtmlPage.RegisterScriptableObject("Credentials", this); //SizeChanged += MainPageSizeChanged; //Create and set map var map = new Map(); mapControl.Map = map; //Initialize the singleton Current.Instance.MapControl = mapControl; //Pass the LayerCollection used on the map to the helper, this is used to distinguish base, normal, ... layers layerHelper = new LayerHelper(map.Layers); Current.Instance.LayerHelper = layerHelper; layerList.SetLayerHelper(layerHelper); //Load the preset layers LayerInitialization.Initialize(layerHelper); hexagonInfo = new HexagonInfo(); hexagonInfo.ReportWindowClosed += hexagonInfo_ReportWindowClosed; landInfoWrapper.Children.Add(hexagonInfo); var flagLayer = Current.Instance.LayerHelper.FindLayer(Constants.flagLayerName) as FlagLayer; if (flagLayer != null) flagLayer.RequestFlags(); scoreRequest.GetByUser(Current.Instance.Earthwatcher.Id); }