@@ -57,6 +57,7 @@ private PlotModel CreateMapPlotView()
5757 Minimum = - 0.24 ,
5858 Maximum = 0.04 ,
5959 Title = "Longitude" ,
60+ //LabelFormatter = (decDegrees) => CartographyHelper.DecimalDegreesToDegreesMinutesSeconds(decDegrees, false, 3)
6061 } ) ;
6162
6263 model . Axes . Add ( new LatitudeWebMercatorAxis
@@ -65,12 +66,16 @@ private PlotModel CreateMapPlotView()
6566 Minimum = 51.42 ,
6667 Maximum = 51.62 ,
6768 Title = "Latitude" ,
69+ //LabelFormatter = (decDegrees) => CartographyHelper.DecimalDegreesToDegreesMinutesSeconds(decDegrees, true, 3)
6870 } ) ;
6971
7072 var tileMapImageProvider = new HttpTileMapImageProvider ( SynchronizationContext . Current )
7173 {
7274 //Url = "https://www.metoffice.gov.uk/public/tiles/map/{Z}/{Y}/{X}.png",
73- Url = "http://tile.openstreetmap.org/{Z}/{X}/{Y}.png" ,
75+ //Url = "https://tile-c.openstreetmap.fr/hot/{Z}/{X}/{Y}.png", // Humanitarian
76+ //Url = "https://gps.tile.openstreetmap.org/lines/{Z}/{X}/{Y}.png", // Public GPS trace
77+ Url = "http://tile.openstreetmap.org/{Z}/{X}/{Y}.png" , // Standard
78+ //Url = "https://b.tile-cyclosm.openstreetmap.fr/cyclosm/{Z}/{X}/{Y}.png", // CyclOSM
7479 //Url = "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}", // https://developers.arcgis.com/documentation/mapping-apis-and-services/data-hosting/services/image-tile-service/
7580 //Url = "https://maptiles.finncdn.no/tileService/1.0.3/norortho/{Z}/{X}/{Y}.png",
7681 //Url = "https://maptiles.finncdn.no/tileService/1.0.3/normap/{Z}/{X}/{Y}.png",
@@ -101,22 +106,6 @@ private PlotModel CreateMapPlotView()
101106 } )
102107 } ;
103108
104- /*
105- var tileMapImageProvider = new LocalTileMapImageProvider()
106- {
107- ImageConverter = new Func<byte[], byte[]>(input =>
108- {
109- using (var msInput = new MemoryStream(input))
110- using (var msOutput = new MemoryStream())
111- {
112- var bitmap = Bitmap.DecodeToWidth(msInput, 256);
113- bitmap.Save(msOutput);
114- return msOutput.ToArray();
115- }
116- })
117- };
118- */
119-
120109 var loadingImg = new Uri ( "avares://SimpleDemo/Assets/live-view.png" ) ;
121110 var asset = AvaloniaLocator . Current . GetService < IAssetLoader > ( ) ;
122111 using ( var streamImg = asset . Open ( loadingImg ) )
@@ -132,6 +121,53 @@ private PlotModel CreateMapPlotView()
132121 } ) ;
133122 }
134123
124+ /*
125+ // Public GPS trace
126+ var tileMapImageProvider2 = new HttpTileMapImageProvider(SynchronizationContext.Current)
127+ {
128+ //Url = "https://www.metoffice.gov.uk/public/tiles/map/{Z}/{Y}/{X}.png",
129+ //Url = "https://tile-c.openstreetmap.fr/hot/{Z}/{X}/{Y}.png", // Humanitarian
130+ Url = "https://gps.tile.openstreetmap.org/lines/{Z}/{X}/{Y}.png", // Public GPS trace
131+ //Url = "http://tile.openstreetmap.org/{Z}/{X}/{Y}.png", // Standard
132+ //Url = "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}", // https://developers.arcgis.com/documentation/mapping-apis-and-services/data-hosting/services/image-tile-service/
133+ //Url = "https://maptiles.finncdn.no/tileService/1.0.3/norortho/{Z}/{X}/{Y}.png",
134+ //Url = "https://maptiles.finncdn.no/tileService/1.0.3/normap/{Z}/{X}/{Y}.png",
135+
136+ MaxNumberOfDownloads = 2,
137+ UserAgent = "OxyPlot.Cartography",
138+ ImageConverter = new Func<byte[], byte[]>(bytes =>
139+ {
140+ // https://github.com/oxyplot/oxyplot/blob/205e968870c292ecaeab2cb9e7f34904897126cb/Source/OxyPlot/Imaging/OxyImage.cs#L221
141+ if (bytes.Length >= 2 && bytes[0] == 0x42 && bytes[1] == 0x4D)
142+ {
143+ return bytes; // Bmp
144+ }
145+
146+ if (bytes.Length >= 4 && bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47)
147+ {
148+ return bytes; //Png
149+ }
150+
151+ using (var msInput = new MemoryStream(bytes))
152+ using (var msOutput = new MemoryStream())
153+ {
154+ var bitmap = Bitmap.DecodeToWidth(msInput, 256);
155+ bitmap.Save(msOutput);
156+ return msOutput.ToArray();
157+ }
158+ return bytes;
159+ })
160+ };
161+
162+ // Add the tile map annotation
163+ model.Annotations.Add(new MapTileAnnotation(tileMapImageProvider2)
164+ {
165+ CopyrightNotice = "© OpenStreetMap contributors",
166+ MinZoomLevel = 0,
167+ MaxZoomLevel = 19, // max OpenStreetMap value
168+ });
169+ */
170+
135171 return model ;
136172 }
137173 }
0 commit comments