Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement .NET MAUI Maps #7886

Merged
merged 154 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
2710dba
Draft maps
rmarinho Jun 8, 2022
52b6273
Get stuff into the manifest
rmarinho Jun 8, 2022
93edaae
[Android] Make it work
rmarinho Jun 8, 2022
bad3bc3
[iOS, Androiid] Add MapType
rmarinho Jun 9, 2022
38d7099
[iOS, Android] Add IsShowingUser
rmarinho Jun 9, 2022
0b3b073
[iOS, Android] Add HasScrollEnabled, HasTrafficEnabled and HasZoomEn…
rmarinho Jun 9, 2022
00b6d45
Add Maps to sandbox
rmarinho Jun 9, 2022
a06fd3b
Fix sandbox manifest
rmarinho Jun 9, 2022
e7574ff
Added to Sample app and fix HasTrafficEnabled iOS
jfversluis Jun 10, 2022
2bed184
Merge branch 'main' into maps
jfversluis Jun 10, 2022
87666e3
Fix IMapHander typo
jfversluis Jun 10, 2022
4fc4a54
More typo fixing
jfversluis Jun 10, 2022
1bbf28f
Merge remote-tracking branch 'origin/main' into maps
jfversluis Jun 13, 2022
18c584f
Make it build
jfversluis Jun 13, 2022
834110b
Implement basic pin support iOS
jfversluis Jun 14, 2022
8d85d1f
Merge branch 'main' into maps
jfversluis Jun 14, 2022
0fa6c15
iOS disconnect events for Pins
jfversluis Jun 14, 2022
c5ce6f5
Update PublicAPI.Unshipped.txt
jfversluis Jun 14, 2022
d2082c8
Add Unshipped APIs
jfversluis Jun 14, 2022
1dc807f
Basic pin tapping iOS
jfversluis Jun 14, 2022
6223a61
[Maps] Move maps to it's own project
rmarinho Jun 24, 2022
888ce31
Merge branch 'net6.0' into maps
rmarinho Jun 24, 2022
20ec8d9
Update more moved files
rmarinho Jun 27, 2022
c4b587b
Merge branch 'net6.0' into maps
rmarinho Jun 27, 2022
a6f0efa
Fixing missing extension
rmarinho Jun 27, 2022
8de3818
Fix map page
rmarinho Jun 27, 2022
08d4cd1
Merge branch 'main' into maps
rmarinho Jun 27, 2022
fbc6e53
Fix api
rmarinho Jun 27, 2022
63d5435
Fix sample
rmarinho Jun 27, 2022
d0560cd
Fix HasTrafficEnabled
rmarinho Jun 27, 2022
b5fdb7b
Add MapArea
rmarinho Jun 27, 2022
c5a36f1
Merge branch 'main' into maps
rmarinho Aug 1, 2022
f48787b
Fix MapType
rmarinho Aug 1, 2022
8f13258
[Maps] Move MapSpan and Distance
rmarinho Aug 1, 2022
d1b486a
Fix android legacy renderer usage
rmarinho Aug 1, 2022
abe8631
Fix ControlGallery Location
rmarinho Aug 2, 2022
2dd8fee
Fix MapSpan
rmarinho Aug 2, 2022
bc3eee4
Add MapClick
rmarinho Aug 2, 2022
5da0403
[Maps] MoveToRegion use command structure
rmarinho Aug 2, 2022
60333a4
[Maps] Make _lastMoveToRegion private
rmarinho Aug 3, 2022
46ce47c
[Maps] Rename clicked event
rmarinho Aug 3, 2022
1bcbb91
[Maps] Fix unit tests
rmarinho Aug 3, 2022
0ff323c
Merge branch 'main' into maps
rmarinho Aug 4, 2022
242179e
Add maps reference to build tasks
rmarinho Aug 4, 2022
b1f364f
[Maps sample] Add pin buttons
rmarinho Aug 4, 2022
a7b3fb0
MauiMapHandlers only exist on iOS and Android for now
rmarinho Aug 4, 2022
63165c0
[Maps] Implement pins on Android
rmarinho Aug 4, 2022
ae19190
[Maps] Add IMapPin handlers
rmarinho Aug 4, 2022
4bee3bf
[Maps] Refactor iOS handler
rmarinho Aug 4, 2022
1757e8f
Fix old rendererers
rmarinho Aug 5, 2022
1d3fee6
Fix build
rmarinho Aug 5, 2022
9bef04c
Add maps to the sln
rmarinho Aug 5, 2022
0900b9a
[Maps] Remove INotifyPropertyChanged from IMapPin
rmarinho Aug 5, 2022
62ff16c
[Maps]Add compile directive
rmarinho Aug 5, 2022
6008001
Add references to maps samples
rmarinho Aug 5, 2022
445758d
Add reference to maps on Profilling
rmarinho Aug 5, 2022
b4e780b
[Maps]Add Remove pin code
rmarinho Aug 5, 2022
8406ab5
Merge branch 'maps' of https://github.com/dotnet/maui into maps
rmarinho Aug 8, 2022
14ee25a
[Maps] Move pins to mapper
rmarinho Aug 8, 2022
9a99335
Add Maps reference to test project
rmarinho Aug 8, 2022
d54c04e
[Maps] Move maps to correct location
rmarinho Aug 8, 2022
a4f0a7e
Fix maps reference
rmarinho Aug 8, 2022
6f63cc9
Remove extra reference on core
rmarinho Aug 8, 2022
b870320
Fix more references
rmarinho Aug 8, 2022
e9d6eea
[Maps] Refactor subscribe/unsubscribe events
rmarinho Aug 8, 2022
0845893
Fix another project reference
rmarinho Aug 8, 2022
26a5d9a
[iOS] Add MapElementHandler
rmarinho Aug 10, 2022
291e319
[Maps] Add Android map elements
rmarinho Aug 10, 2022
12c4354
[Android] Add MapElementHandler for Android
rmarinho Aug 10, 2022
9d6fbd8
[Maps] Remove Geocoder and Position
rmarinho Aug 11, 2022
a8ce7d8
[Maps] Null enabled on Controls.Maps
rmarinho Aug 11, 2022
d1777d9
Merge branch 'main' into maps
rmarinho Aug 11, 2022
15140a1
[Maps] Remove more Geocoder usage
rmarinho Aug 11, 2022
b7f6f9a
Remove more geocoder
rmarinho Aug 11, 2022
18db13d
Merge branch 'main' into maps
rmarinho Aug 11, 2022
af48bd3
[Maps] Fix a couple of old references
rmarinho Aug 11, 2022
796555c
Fix Circle extension
rmarinho Aug 11, 2022
6bd2069
Move to MAUI :D
rmarinho Aug 11, 2022
fbf3c53
Update Location usage on Xaml
rmarinho Aug 11, 2022
d59560d
Fix old renderer
rmarinho Aug 11, 2022
de9e203
Fix maui location
rmarinho Aug 11, 2022
fda5ca2
[Maps] Add Tizen handlers
rmarinho Aug 11, 2022
38065c4
[Maps] Try use ElmSharp.EvasObject
rmarinho Aug 11, 2022
8abf41a
Fix Tizen
rmarinho Aug 12, 2022
75bb059
Merge branch 'main' into maps
rmarinho Aug 12, 2022
5f4f949
Fix test
jfversluis Aug 12, 2022
4142361
[Maps] Fix Map tests
rmarinho Aug 12, 2022
0334fdc
Merge branch 'maps' of https://github.com/dotnet/maui into maps
rmarinho Aug 12, 2022
611339e
Try fix tests, fix some formatting
rmarinho Aug 12, 2022
a8ca072
FIx test again
rmarinho Aug 12, 2022
0cf228b
Merge branch 'main' into maps
rmarinho Aug 16, 2022
e968254
[Maps] Use AddMauiMaps without if/def
rmarinho Aug 16, 2022
a00aafc
[iOS] Don't set _handler to null
rmarinho Aug 16, 2022
3c54b4b
[Tizen] Remove disable warnings
rmarinho Aug 16, 2022
287bb82
[iOS] Move GestureRecognizer to MauiMKMapView
rmarinho Aug 16, 2022
dbd44e7
[iOS] Throw exception if no MKOverlayRenderer is found for IMKOverlay
rmarinho Aug 16, 2022
2f25ee3
[Maps] Remove Geopath from the IGeoPathMapElement
rmarinho Aug 16, 2022
3308939
[Maps] Use WeakReference for Handler on iOS MAuiMKMapView
rmarinho Aug 16, 2022
8042006
[iOS] Fix check of MapElementId when creating MapElement handler
rmarinho Aug 16, 2022
7273198
Pack the maps things
mattleibow Aug 16, 2022
97ac4a3
Merge branch 'main' into maps
mattleibow Aug 16, 2022
f8a3ccc
pack
mattleibow Aug 16, 2022
f87755a
[Maps] Fix update mapElements for iOS and Android
rmarinho Aug 17, 2022
ea3445d
[Maps] Map needscall MapElementUpdate on PropertyChanged
rmarinho Aug 17, 2022
e5b5580
Merge branch 'maps' of https://github.com/dotnet/maui into maps
rmarinho Aug 17, 2022
2f720ec
[Maps] VisibleRegion shouldn't have a public setter
rmarinho Aug 17, 2022
0dd6af1
[Maps] Move Pin Position property to Location
rmarinho Aug 17, 2022
6f54bbd
[Maps] Remove MoveToLastRegionOnLayoutChange
rmarinho Aug 17, 2022
5d1d9e6
Use MauiMKMapView
rmarinho Aug 17, 2022
aed9262
Fix build
rmarinho Aug 17, 2022
e5b1195
Small refactor on sample page
rmarinho Aug 17, 2022
632a4d0
Remove extra references
rmarinho Aug 17, 2022
9659fb9
Fix Map API for MapElements and Pins
rmarinho Aug 17, 2022
3d1bdc0
Fix unittests projec
rmarinho Aug 17, 2022
2418ff3
Merge remote-tracking branch 'origin/main' into maps
mattleibow Aug 17, 2022
ad4be3e
Update Maui.Controls.Sample.csproj
mattleibow Aug 17, 2022
46b9fd9
Update Controls.Maps.csproj
mattleibow Aug 17, 2022
42c6eb4
fix all that
mattleibow Aug 17, 2022
381e526
Fix some build errors
jfversluis Aug 18, 2022
4f1c6cd
Fix PinTests
rmarinho Aug 18, 2022
4f2a6d4
Update MapWithItemsSourceGallery.xaml
jfversluis Aug 18, 2022
c38b7d9
Fix last test
jfversluis Aug 18, 2022
edbbdb7
Update dotnet.cake
mattleibow Aug 18, 2022
75f81c6
Implement UseMauiMaps
jfversluis Aug 19, 2022
a559834
Complete UseMauiMaps for Android
jfversluis Aug 19, 2022
86d53b6
[BuildTasks]Remove reference to maps
rmarinho Aug 19, 2022
73cf5dc
Cleaup up sample
rmarinho Aug 19, 2022
679b0fc
[Maps] Don't make VisibleRegion setter public on Controls
rmarinho Aug 19, 2022
95e9993
Add public api for Controls.Maps
rmarinho Aug 19, 2022
0b96223
[Maps] Add Public api for Maps.Core
rmarinho Aug 19, 2022
d0fc919
Add public API for Core.Map
rmarinho Aug 19, 2022
7bf0720
Add more public
rmarinho Aug 19, 2022
a9f4581
Update Maps.csproj
mattleibow Aug 19, 2022
c131735
Merge branch 'main' into maps
mattleibow Aug 19, 2022
853140f
Merge branch 'main' into maps
rmarinho Aug 23, 2022
39df840
Added more samples to the gallery
jsuarezruiz Aug 25, 2022
cd40593
[Maps] Update windows handler to be more generic
rmarinho Aug 25, 2022
0a97153
Merge branch 'maps' of https://github.com/dotnet/maui into maps
rmarinho Aug 25, 2022
499e60b
Updated samples
jsuarezruiz Aug 25, 2022
cd5aaf9
Merge branch 'maps' of https://github.com/dotnet/maui into maps
jsuarezruiz Aug 25, 2022
4170b75
[Android] Update obsolete android API
rmarinho Aug 25, 2022
b603d66
Merge branch 'maps' of https://github.com/dotnet/maui into maps
rmarinho Aug 25, 2022
eb3f58d
[Maps] Remove usage of old geocoder
rmarinho Aug 25, 2022
6819e36
[Maps] Remove EditorBrowsable
rmarinho Aug 25, 2022
2657367
[Maps] Change Position to Location on MapClickedEventArgs
rmarinho Aug 25, 2022
c3c331f
Fix sample
jsuarezruiz Aug 25, 2022
f1b3073
[Maps] update some wording that was referencing forms
rmarinho Aug 25, 2022
5884dc3
Merge branch 'maps' of https://github.com/dotnet/maui into maps
jsuarezruiz Aug 25, 2022
fcdac2b
[Maps]Fix more old usage of Position
rmarinho Aug 25, 2022
415337b
[Maps]Check if Location is null before setting Pin Location on Android
rmarinho Aug 25, 2022
97dc5ce
[Maps] Don't use obsolete api
rmarinho Aug 25, 2022
edf32c8
[Maps] Rename properties from Has to Is
rmarinho Aug 25, 2022
e9dee01
Merge branch 'main' into maps
rmarinho Aug 26, 2022
dc7139a
[Maps] Rename properties on Controls.Maps
rmarinho Aug 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Microsoft.Maui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedSource", "SharedSourc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks.Droid", "src\Core\tests\Benchmarks.Droid\Benchmarks.Droid.csproj", "{5B56A734-D53C-4635-A53E-F889FCFCDD66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maps", "src\Core\maps\src\Maps.csproj", "{E8728693-3537-4007-A4DB-9F9634548755}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Graphics", "Graphics", "{E4884871-4A1B-43BC-814F-E3D6E52B1673}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{42AB9AE1-631D-4AD4-85B7-910FF0940BDB}"
Expand Down Expand Up @@ -542,6 +544,10 @@ Global
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Release|Any CPU.Build.0 = Release|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Release|Any CPU.Deploy.0 = Release|Any CPU
{E8728693-3537-4007-A4DB-9F9634548755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8728693-3537-4007-A4DB-9F9634548755}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8728693-3537-4007-A4DB-9F9634548755}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8728693-3537-4007-A4DB-9F9634548755}.Release|Any CPU.Build.0 = Release|Any CPU
{CF056C95-51C4-4366-9D06-41D2B15EFEE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF056C95-51C4-4366-9D06-41D2B15EFEE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF056C95-51C4-4366-9D06-41D2B15EFEE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -718,6 +724,7 @@ Global
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{4F2926C8-43AB-4328-A735-D9EAD699F81D} = {ED7F28E0-D0AF-417D-983D-3D874EEE8554}
{5B56A734-D53C-4635-A53E-F889FCFCDD66} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{E8728693-3537-4007-A4DB-9F9634548755} = {E8AD265B-3C67-4640-AC58-A522F9FB3361}
{42AB9AE1-631D-4AD4-85B7-910FF0940BDB} = {E4884871-4A1B-43BC-814F-E3D6E52B1673}
{1BA0121E-0B83-4C8F-81BE-C293E7E35DCE} = {E4884871-4A1B-43BC-814F-E3D6E52B1673}
{936C47A9-A7EA-4FBD-8733-CED1D4100E69} = {E4884871-4A1B-43BC-814F-E3D6E52B1673}
Expand Down
9 changes: 8 additions & 1 deletion _omnisharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Controls", "Controls", "{45
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E1082E26-D700-4127-9329-66D673FD2D55}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Maui.Controls.Sample", "src\Controls\samples\Controls.Sample\Maui.Controls.Sample.csproj", "{B8DC1324-977C-46F1-B697-9064ADE6099A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maui.Controls.Sample", "src\Controls\samples\Controls.Sample\Maui.Controls.Sample.csproj", "{B8DC1324-977C-46F1-B697-9064ADE6099A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compatibility", "Compatibility", "{123AA89E-1638-4E0E-B828-B8F9F9F906A2}"
EndProject
Expand Down Expand Up @@ -92,6 +92,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.DeviceTests", "src\Cor
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controls.Foldable", "src\Controls\Foldable\src\Controls.Foldable.csproj", "{F0A48792-ACD7-4B72-83EB-C56A70FA5A3A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maps", "src\Core\maps\src\Maps.csproj", "{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -205,6 +207,10 @@ Global
{F0A48792-ACD7-4B72-83EB-C56A70FA5A3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0A48792-ACD7-4B72-83EB-C56A70FA5A3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0A48792-ACD7-4B72-83EB-C56A70FA5A3A}.Release|Any CPU.Build.0 = Release|Any CPU
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -247,6 +253,7 @@ Global
{7BEF8AD2-3A1D-4920-9036-473B9A6D5B0D} = {FBA6A516-2B6A-48A9-B64F-B012114B9501}
{50BCB5CD-DC2A-42AA-B921-D99B19625CE1} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{F0A48792-ACD7-4B72-83EB-C56A70FA5A3A} = {50C758FE-4E10-409A-94F5-A75480960864}
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035} = {E8AD265B-3C67-4640-AC58-A522F9FB3361}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B8ABEAD-D2B5-4370-A187-62B5ABE4EE50}
Expand Down
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<_XamarinAndroidGlideVersion>4.13.2.1</_XamarinAndroidGlideVersion>
<_XamarinAndroidXSecurityVersion>1.1.0-alpha03</_XamarinAndroidXSecurityVersion>
<_XamarinGoogleCryptoTinkAndroidVersion>1.6.1.7</_XamarinGoogleCryptoTinkAndroidVersion>
<!-- Android Maps -->
<XamarinGooglePlayServicesMaps>117.0.0</XamarinGooglePlayServicesMaps>
<!--
SKIASHARP & HARFBUZZSHARP - the various things must be kept in sync with maui graphics:
- NuGet versions below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Maui.Controls.Maps;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Maps;
using Map = Microsoft.Maui.Controls.Maps;

namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.GalleryPages
Expand Down Expand Up @@ -31,7 +32,7 @@ public MapElementsGallery()

Map.MoveToRegion(
MapSpan.FromCenterAndRadius(
new Position(39.828152, -98.569817),
new Devices.Sensors.Location(39.828152, -98.569817),
rmarinho marked this conversation as resolved.
Show resolved Hide resolved
Distance.FromMiles(1681)));

_polyline = new Maps.Polyline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Maps;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Devices.Sensors;
using Microsoft.Maui.Maps;

namespace Microsoft.Maui.Controls.Compatibility.ControlGallery
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MapGallery : ContentPage
{
readonly Geocoder _geocoder = new Geocoder();
//readonly Geocoder _geocoder = new Geocoder();
rmarinho marked this conversation as resolved.
Show resolved Hide resolved
readonly Map Map;

public MapGallery()
Expand All @@ -25,8 +27,8 @@ public MapGallery()
Map = MakeMap();
Map.Pins.ToList().ForEach(pin =>
{
pin.MarkerClicked += MarkerClicked;
pin.InfoWindowClicked += InfoWindowClicked;
(pin as Pin).MarkerClicked += MarkerClicked;
rmarinho marked this conversation as resolved.
Show resolved Hide resolved
(pin as Pin).InfoWindowClicked += InfoWindowClicked;
});
Map.MapClicked += MapClicked;

Expand All @@ -37,29 +39,29 @@ public MapGallery()

public static Map MakeMap()
{
return new Map(MapSpan.FromCenterAndRadius(new Position(41.890202, 12.492049), Distance.FromMiles(0.5)))
return new Map(MapSpan.FromCenterAndRadius(new Devices.Sensors.Location(41.890202, 12.492049), Distance.FromMiles(0.5)))
{
IsShowingUser = false,
Pins =
{
new Pin
{
Type = PinType.Place,
Position = new Position (41.890202, 12.492049),
Position = new Location(41.890202, 12.492049),
Label = "Colosseum",
Address = "Piazza del Colosseo, 00184 Rome, Province of Rome, Italy"
},
new Pin
{
Type = PinType.Place,
Position = new Position (41.898652, 12.476831),
Position = new Location (41.898652, 12.476831),
Label = "Pantheon",
Address = "Piazza della Rotunda, 00186 Rome, Province of Rome, Italy"
},
new Pin
{
Type = PinType.Place,
Position = new Position (41.903209, 12.454545),
Position = new Location (41.903209, 12.454545),
Label = "Sistine Chapel",
Address = "Piazza della Rotunda, 00186 Rome, Province of Rome, Italy"
}
Expand Down Expand Up @@ -89,23 +91,23 @@ void InfoWindowClicked(object sender, PinClickedEventArgs e)

async void SearchForAddress(object sender, EventArgs e)
{
var searchAddress = (SearchBar)sender;
var addressQuery = searchAddress.Text;
searchAddress.Text = "";
searchAddress.Unfocus();
//var searchAddress = (SearchBar)sender;
rmarinho marked this conversation as resolved.
Show resolved Hide resolved
//var addressQuery = searchAddress.Text;
//searchAddress.Text = "";
//searchAddress.Unfocus();

var positions = (await _geocoder.GetPositionsForAddressAsync(addressQuery)).ToList();
if (!positions.Any())
return;
//var positions = (await _geocoder.GetPositionsForAddressAsync(addressQuery)).ToList();
//if (!positions.Any())
// return;

var position = positions.First();
Map.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromMeters(4000)));
Map.Pins.Add(new Pin
{
Label = addressQuery,
Position = position,
Address = addressQuery
});
//var position = new Location(positions.First().Latitude, positions.First().Longitude);
//Map.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromMeters(4000)));
//Map.Pins.Add(new Pin
//{
// Label = addressQuery,
// Position = position,
// Address = addressQuery
//});
}

void MapClicked(object sender, MapClickedEventArgs e)
Expand Down Expand Up @@ -142,32 +144,32 @@ void ZoomOutClicked(object sender, EventArgs e)

async void ReverseGeocodeClicked(object sender, EventArgs e)
{
var addresses = await _geocoder.GetAddressesForPositionAsync(new Position(41.8902, 12.4923));
foreach (var ad in addresses)
Debug.WriteLine(ad);
//var addresses = await _geocoder.GetAddressesForPositionAsync(new Position(41.8902, 12.4923));
rmarinho marked this conversation as resolved.
Show resolved Hide resolved
//foreach (var ad in addresses)
// Debug.WriteLine(ad);
}

void HomeClicked(object sender, EventArgs e)
{
Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(41.890202, 12.492049), Distance.FromMiles(0.5)));
Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Devices.Sensors.Location(41.890202, 12.492049), Distance.FromMiles(0.5)));
}

void ZoomPinClicked(object sender, EventArgs e)
{
var pos = new Position(41.011995, -8.642995);
var pos = new Devices.Sensors.Location(41.011995, -8.642995);
Map.Pins.Clear();
Map.Pins.Add(new Pin { Position = pos, Label = "Rui" });
Map.MoveToRegion(MapSpan.FromCenterAndRadius(pos, Distance.FromMiles(0.5)));
}

void EditPinClicked(object sender, EventArgs e)
{
var pin = Map.Pins.First();
var pin = (Pin)Map.Pins.First();

pin.Label += " Edited";
pin.Address = "Edited";

var pos = new Position(pin.Position.Latitude + 1, pin.Position.Longitude + 1);
var pos = new Devices.Sensors.Location(pin.Position.Latitude + 1, pin.Position.Longitude + 1);
pin.Position = pos;
Map.MoveToRegion(MapSpan.FromCenterAndRadius(pos, Distance.FromMiles(0.5)));
}
Expand All @@ -186,7 +188,7 @@ void ToggleMoveToLastRegionOnLayoutChange(object sender, EventArgs e)
void ShowTrafficToggled(object sender, ToggledEventArgs e)
{
var control = (Switch)sender;
Map.TrafficEnabled = control.IsToggled;
Map.HasTrafficEnabled = control.IsToggled;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Maps;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Devices.Sensors;
using Microsoft.Maui.Maps;

namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.GalleryPages
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MapWithItemsSourceGallery : ContentPage
{
static readonly Position startPosition = new Position(39.8283459, -98.5794797);
static readonly Location startPosition = new Location(39.8283459, -98.5794797);

public MapWithItemsSourceGallery()
{
Expand All @@ -41,9 +43,9 @@ class ViewModel
public ViewModel()
{
_places = new ObservableCollection<Place>() {
new Place("New York, USA", "The City That Never Sleeps", new Position(40.67, -73.94)),
new Place("Los Angeles, USA", "City of Angels", new Position(34.11, -118.41)),
new Place("San Francisco, USA", "Bay City ", new Position(37.77, -122.45))
new Place("New York, USA", "The City That Never Sleeps", new Location(40.67, -73.94)),
new Place("Los Angeles, USA", "City of Angels", new Location(34.11, -118.41)),
new Place("San Francisco, USA", "Bay City ", new Location(37.77, -122.45))
};

AddPlaceCommand = new Command(AddPlace);
Expand Down Expand Up @@ -85,7 +87,7 @@ await Task.Run(() =>

foreach (Place place in Places)
{
place.Position = new Position(lastLatitude, place.Position.Longitude);
place.Position = new Location(lastLatitude, place.Position.Longitude);
}
});
}
Expand All @@ -107,16 +109,9 @@ static class RandomPosition
{
static Random Random = new Random(Environment.TickCount);

public static Position Next()
public static Location Next(Location position, double latitudeRange, double longitudeRange)
{
return new Position(
latitude: Random.NextDouble() * 180 - 90,
longitude: Random.NextDouble() * 360 - 180);
}

public static Position Next(Position position, double latitudeRange, double longitudeRange)
{
return new Position(
return new Location(
latitude: position.Latitude + (Random.NextDouble() * 2 - 1) * latitudeRange,
longitude: position.Longitude + (Random.NextDouble() * 2 - 1) * longitudeRange);
}
Expand All @@ -129,22 +124,22 @@ Place NewPlace()
return new Place(
$"Pin {_pinCreatedCount}",
$"Desc {_pinCreatedCount}",
RandomPosition.Next(startPosition, 8, 19));
RandomPosition.Next(startPosition, 8, 19));
}
}

[Preserve(AllMembers = true)]
class Place : INotifyPropertyChanged
{
Position _position;
Location _position;

public event PropertyChangedEventHandler PropertyChanged;

public string Address { get; }

public string Description { get; }

public Position Position
public Location Position
{
get => _position;
set
Expand All @@ -157,7 +152,7 @@ public Position Position
}
}

public Place(string address, string description, Position position)
public Place(string address, string description, Location position)
{
Address = address;
Description = description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ public static Map MakeMap()
Pins = {
(colosseum = new Pin {
Type = PinType.Place,
Position = new Position (41.890202, 12.492049),
Position = new Devices.Sensors.Location (41.890202, 12.492049),
Label = "Colosseum",
Address = "Piazza del Colosseo, 00184 Rome, Province of Rome, Italy"
}),
(pantheon = new Pin {
Type = PinType.Place,
Position = new Position (41.898652, 12.476831),
Position = new Devices.Sensors.Location (41.898652, 12.476831),
Label = "Pantheon",
Address = "Piazza della Rotunda, 00186 Rome, Province of Rome, Italy"
}),
(chapel = new Pin {
Type = PinType.Place,
Position = new Position (41.903209, 12.454545),
Position = new Devices.Sensors.Location (41.903209, 12.454545),
Label = "Sistine Chapel",
Address = "Piazza della Rotunda, 00186 Rome, Province of Rome, Italy"
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override void Init()
Text = "Add pins",
Command = new Command (() => {
foreach (var pin in map.Pins) {
pin.MarkerClicked -= PinClicked;
(pin as Pin).MarkerClicked -= PinClicked;
}

map.Pins.Clear ();
Expand All @@ -57,7 +57,7 @@ protected override void Init()
Address = "address",
Label = "label",
Type = PinType.Place,
Position = new Position (map.VisibleRegion.Center.Latitude + lat, map.VisibleRegion.Center.Longitude + lng)
Position = new Devices.Sensors.Location (map.VisibleRegion.Center.Latitude + lat, map.VisibleRegion.Center.Longitude + lng)
};

pin.MarkerClicked += PinClicked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
using Microsoft.Maui.Controls.CustomAttributes;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Maps;

using Microsoft.Maui.Maps;
using Microsoft.Maui.Devices.Sensors;

namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues
{
Expand Down Expand Up @@ -56,7 +57,7 @@ protected override void Init()
public void DisplayMaps()
{
map2.IsVisible = false;
var mapPinPosition = new Position(Latitude, Longitude);
var mapPinPosition = new Location(Latitude, Longitude);

var type = MapType.Satellite;
map1.MapType = type;
Expand Down
Loading