Comments (5)
Funny thing that yesterday i merged pull request with this fix. Someone had this issue too.
Now you could set any type value to height and it will be used in map style like "height: {Height}"
Nuget will be available in minutes (just added now). Then let me know if it helped.
https://www.nuget.org/packages/BlazorGoogleMaps/0.6.2
from blazorgooglemaps.
I'm sorry to say that the last change didn't help at all.
The last change were a breaking change that requires that the value of height to be set as a string ending with px
.
Percent %
doesn't work. If you set the value to a percent value like 90% (or any other value that not ends with ...px
), no map will be shown at all.
I used the @OnAfterInit
to check the height of the mapControl, see the comments in @OnAfterInit
below :
@using GoogleMapsComponents
@using GoogleMapsComponents.Maps;
@inject BrowserService BrowserService
<style>
body {
padding: 0px;
}
.container-fluid {
padding: 0px;
}
.vehicle-map{
height: 100%
}
</style>
<div class="container-fluid">
<GoogleMap @ref="@_mapControl" Id="vehicleMap" Options="@_mapControlOptions"
CssClass="vehicle-map" Height="@Height" OnAfterInit="@OnAfterInit"></GoogleMap>
</div>
@code {
private int _height = 400;
public string Height
{
get { return _height.ToString() + "px"; }
}
protected GoogleMap _mapControl { get; set; }
protected MapOptions _mapControlOptions { get; set; }
protected override void OnInitialized()
{
_mapControlOptions = new MapOptions()
{
Zoom = 15,
Center = new LatLngLiteral()
{
Lat = 57.6564035,
Lng = 12.0201743
},
MapTypeId = MapTypeId.Roadmap
};
}
async Task GetDimensions()
{
var dimension = await BrowserService.GetDimensions();
_height = dimension.Height;
}
protected override async Task OnInitializedAsync()
{
System.Diagnostics.Debug.WriteLine(_mapControl?.Height); //_mapControl = null
await GetDimensions();
System.Diagnostics.Debug.WriteLine(_mapControl?.Height); // _mapControl.Height = 400px
}
private void OnAfterInit()
{
System.Diagnostics.Debug.WriteLine(_mapControl.Height); //_mapControl.Height = 865px
StateHasChanged();
// Althought _mapControl.Height = 865px, the size of the control on the page is 400px.
}
}
from blazorgooglemaps.
I dont think it is related to BlazorGoogleMaps directly, but i could be wrong.
I will try reproduce this weekend.
Could you check these solutions.
https://stackoverflow.com/questions/10209704/set-google-maps-container-div-width-and-height-100
from blazorgooglemaps.
First of all you miss some point of blazor binding. "Dynamic" value binding is archived using with @bind- . So far Height is one way binding property and wont work this way. Google maps have strange behaviors to override style and dynamic binding wont work (i think there is somewhere strange workaround).
You way is to set google maps height to "" then google map will use parent container height and then you could control parent container height with your code.
I added just peace of code which will help you find right path. Let me know if it helps
<button @onclick="@ChangeSize">ChangeSize</button>
<div style="height: @($" {MapHH}");">
<GoogleMap @ref="@_mapControl" Id="vehicleMap" Options="@_mapControlOptions"
CssClass="vehicle-map" Height="" OnAfterInit="@OnAfterInit"></GoogleMap>
</div>
@code {
private int _height = 400;
public string MapHH { get; set; }
public string Height
{
get { return _height.ToString() + "px"; }
}
protected GoogleMap _mapControl { get; set; }
protected MapOptions _mapControlOptions { get; set; }
private void ChangeSize()
{
MapHH = "550px";
StateHasChanged();
}
from blazorgooglemaps.
Above needs on small change. Height set to "" makes map not show. Height needs to be set to 100%
from blazorgooglemaps.
Related Issues (20)
- Accessing the map object via javascript HOT 4
- Working with encoded polylines. HOT 2
- Multiple Ground Overlays HOT 3
- DrawingManager.SetDrawingMode no longer works in 3.3.2 and newer HOT 7
- Add class DragEndEvent for dragend listener (Suggestion) HOT 1
- MarkerClustering - Set Click on Zoom level; HOT 2
- polygonList not rendering the polygons HOT 9
- Advanced Markers server side demo dont work anymore HOT 4
- Link KeyProvider to map object scope instead of application level static HOT 2
- Advanced Marker Support HOT 4
- AdvancedMapMarker Microsoft.JSInterop.JSException: function not found HOT 1
- Enabling Dependabot for repository
- AdvancedMarkerElementOptions - Content Invalid (not an instance of Node) HOT 13
- New method services.AddBlazorGoogleMaps("YOUR_KEY_GOES_HERE"); only is used in Maps, not other components HOT 1
- Blazor web app demo HOT 1
- Removed map HTMLElement from DOM still try to render map HOT 14
- Add Support for PinElement (AdvancedMarkerElement Customization) HOT 8
- AdvancedMarker from svg HOT 4
- Add way to set AdvancedMarker properties HOT 6
- Feature: Traffic, Transit and Bicycle Layer HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazorgooglemaps.