Skip to content

Commit a75b7b0

Browse files
committed
Added comments for maps restrictions.
1 parent 275eeb7 commit a75b7b0

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

.github/docs/Maps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Maps using `IGeolocationService` (see "Dependences") to center current position.
3434
It can be omitted and injected separately to your components as well to get or track device location.
3535
To see how it works please check **Geo JS** [documentation](https://github.com/majorimi/blazor-components/blob/master/.github/docs/JsInterop.md#geolocation-js-see-demo-app) and [demo](https://blazorextensions.z6.web.core.windows.net/jsinterop#geo-js).
3636

37+
3738
## `GoogleStaticMap` component (See: [demo app](https://blazorextensions.z6.web.core.windows.net/maps#google-static-maps))
3839

3940
:warning: **To use Google Maps Platform, you must have a billing account. The billing account is used to track costs associated with your projects.**
@@ -98,7 +99,6 @@ Once operation has finished successfully `OnLocationDetected` event will be fire
9899
- **`DisposeAsync()`: `Task DisposeAsync()`** <br />
99100
Component implements `IAsyncDisposable` interface Blazor framework will call it when parent removed from render tree.
100101

101-
102102
## `GoogleMap` component (See: [demo app](https://blazorextensions.z6.web.core.windows.net/maps#google-js-maps))
103103

104104
:warning: **To use Google Maps Platform, you must have a billing account. The billing account is used to track costs associated with your projects.**

src/Majorsoft.Blazor.Components.Maps/Google/GoogleMap.razor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
},
138138
mapZoomChangedCallback: async (zoom) =>
139139
{
140-
WriteDiag($"Map Zoom level changed to: '{zoom}'.");
140+
WriteDiag($"Map Zoom level callback changed to: '{zoom}'.");
141141
if (_zoomLevel == zoom)
142142
return;
143143

@@ -336,6 +336,8 @@
336336
if (_mapInitialized && value != _zoomLevel)
337337
{
338338
_zoomLevel = value;
339+
340+
WriteDiag($"Map Zoom level property Set to: '{_zoomLevel}'.");
339341
InvokeAsync(async () => await _mapService.SetZoomAsync(_zoomLevel));
340342
}
341343
}

src/Majorsoft.Blazor.Components.Maps/Google/GoogleMapRestriction.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{
33
/// <summary>
44
/// Restrictions coordinates for <see cref="GoogleMap"/>
5+
/// NOTE: Google Maps restriction is basically a MAX Zoom level. So it does not allow users to zoom out (zoom level value forced).
6+
/// In order to notify Blazor about the maximum Zoom level two-way binding MUST be used: `@bind-Zoom="_jsMapZoomLevel" @bind-Zoom:event="OnMapZoomLevelChanged"`
57
/// </summary>
68
public class GoogleMapRestriction
79
{

src/Majorsoft.Blazor.Components.Maps/Majorsoft.Blazor.Components.Maps.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Majorsoft.Blazor.Components.TestApps.Common/Components/MapsGoogle.razor

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,12 @@
241241
<div class="row pb-2">
242242
<div class="col-12 col-lg-8 col-xl-6">
243243
<p>
244-
<strong>Maps Pre-render settings</strong>: Background color: <strong style="color: @_jsMapBackgroundColor;">@_jsMapBackgroundColor</strong>
245-
Control size: <strong>@(_jsMapControlSize)px</strong> <br />
246-
Restrict map to New Zealand: <input class="mr-2" type="checkbox" @bind="_jsRestrictMap" disabled="disabled" />
244+
<h5>Maps Pre-render settings:</h5>
245+
<ul>
246+
<li>Background color: <strong style="color: @_jsMapBackgroundColor;">@_jsMapBackgroundColor</strong></li>
247+
<li>Control size: <strong>@(_jsMapControlSize)px</strong></li>
248+
<li>Restrict map to New Zealand: <input class="mr-2" type="checkbox" @bind="_jsRestrictMap" disabled="disabled" /></li>
249+
</ul>
247250
</p>
248251
</div>
249252
</div>
@@ -260,7 +263,7 @@
260263
ControlSize="@_jsMapControlSize"
261264
Center="@_jsMapCenter"
262265
AnimateCenterChange="@_jsMapAnimateCenterChange"
263-
Zoom="@_jsMapZoomLevel"
266+
@bind-Zoom="_jsMapZoomLevel" @bind-Zoom:event="OnMapZoomLevelChanged"
264267
ZoomControl="@_jsZoomControl"
265268
ZoomControlOptionsPosition="GoogleMapControlPositions.RIGHT_BOTTOM"
266269
MaxZoom="null"
@@ -298,7 +301,6 @@
298301
OnMapMouseOver="@OnMapMouseOver"
299302
OnMapMouseOut="@OnMapMouseOut"
300303
OnMapCenterChanged="@OnMapCenterChanged"
301-
OnMapZoomLevelChanged="@OnMapZoomLevelChanged"
302304
OnMapTypeChanged="@OnMapTypeChanged"
303305
OnMapHeadingChanged="@OnMapHeadingChanged"
304306
OnMapTiltChanged="@OnMapTiltChanged"
@@ -533,7 +535,7 @@
533535
private bool _jsScaleControl = true;
534536
private bool _jsStreetViewControl = true;
535537
private bool _jsZoomControl = true;
536-
private bool _jsRestrictMap = false;
538+
private bool _jsRestrictMap = false; //must be set before Init...
537539
538540
private List<GoogleMapCustomControl> _jsCustomControls = new List<GoogleMapCustomControl>();
539541
private ObservableRangeCollection<GoogleMapMarker> _jsMarkers = new ObservableRangeCollection<GoogleMapMarker>();
@@ -709,15 +711,6 @@
709711
//Center point can be accessed as well with method call
710712
var center = await _googleMap.GoogleMapService.GetCenterAsync();
711713
}
712-
private async Task OnMapZoomLevelChanged(byte zoom)
713-
{
714-
//Can be used with Binding and custom event: @bind-Zoom="_jsMapZoomLevel" @bind-Zoom:event="OnMapZoomLevelChanged"
715-
if (_logOtherEvents)
716-
{
717-
_mapsLog = await WriteLog(_mapsLog, $"Map Zoom level changed to: {zoom}");
718-
}
719-
_jsMapZoomLevel = zoom; //Two-way binding with event value
720-
}
721714
private async Task OnMapTypeChanged(GoogleMapTypes googleMapTypes)
722715
{
723716
//Can be used with Binding and custom event: @bind-MapType="_jsMapType" @bind-MapType:event="OnMapTypeChanged"

0 commit comments

Comments
 (0)