Complete view of OpenLayers map in the UI window

I am currently working on an angularjs app with Angular Material built using the yeoman fullstack generator. In my index.html file, I have a navbar and a ui-view that displays the site's content.

<!-- index.html --!>
<!-- Add your site or application content here -->
<div ng-include="'components/navbar/navbar.html'"></div>
<div ui-view></div>

When loading the main.html page, the

<div ng-include="'app/map/map.html'"></div>
contains an openlayers map that does not fill the window as intended due to its height being inconsistent. There is also a direct route for accessing the map.

Adjusting the ui-view's height to 100% has not been successful and it does not meet the specific requirements. The map itself should take up 100% of the screen while other elements loaded in the ui-view should not. I am seeking assistance in getting this map to occupy the entire window.

The map.html file loads the open layers directive which can be found here. Additionally, I attempted using flex from angular material without success. It seems there must be a way to achieve this task, but despite my efforts to add height and/or flex tags to various DOM elements, I have not succeeded.

Answer №1

If you are looking to implement a full-height openlayers map in a ui-view using angular material with a toolbar, here is a simple solution:

Make sure that both body and html elements have their height set to 100%.

<div layout="column" style="height: 100%">
    <div ng-include="'components/navbar/navbar.html'"></div>
    <ui-view flex style="position:relative;"></ui-view>
</div>

Within the ui-view, place something like the following (or wrap your openlayers map in another element):

<openlayers style="position: absolute" width="100%" height="100%">        
</openlayers>

The key is to utilize position: absolute on the children within [flex].

UPDATE

Don't forget that the div containing the layout attribute should also be full height.

Check out this jsfiddle for a live demo: http://jsfiddle.net/kvetis/k3wm4tzp/3/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Achieving a function call within a Backbone view in Backbone.js

Is it possible to call the plotPort function from the plotLoc function using this.plotPort() instead of self.plotPort()? It seems to not work for Internet Explorer when using self.plotPort(). As a workaround, I added an event to lLoca upon reset to call ...

Tips for transferring a data table (an object) from a JavaScript file to Node.js

On my HTML page, there is a table displaying student names and information, along with controls to manage the table. I created a save button to save this table as an object named SIT in my JavaScript code. I was able to manually save this table in MongoDB ...

Sharing data between components in Angular Material

My goal is to achieve a task that would typically be done with a Global variable in a database management system. I am attempting to transfer data from one component to another using a service. These components are like siblings, located in the components ...

Feeling anxious about the abundance of fields within the table

Currently in the process of planning my upcoming project, a text-based MMORPG game. I'm tackling the design of certain aspects of the database and have encountered a new challenge. One feature of the game involves allowing players to purchase cars and ...

Achieving a Side-Along Sidebar with CSS, Fully Embracing

I'm encountering an issue with achieving 100% height using CSS. Despite my extensive search for tutorials and solutions, I haven't been able to achieve the desired results. My layout consists of a sidebar and a main column where the content will ...

Trouble with Two Divs Layout

My website layout includes links on the left side of the page within a floating div, with content on the right side in another floating div. However, I'm facing an issue where the content moves below the links when the page is resized. I attempted to ...

A versatile function that displays a loading icon on top of a specified div

Is it possible to pass an identifier for a particular div element to a function, where the function will display a loading image that covers the entire div, and then pass the same identifier to another function to hide the loading image? I am looking to cr ...

What is the best way to store HTML in a variable as a string?

Imagine if I have a variable: let display_text = "Cats are pawsome!" I aim to show it as such: <div> <b>Cats</b> are pawsome! </div> To be clear, dynamically enclose the word "cats" whenever it shows up. ...

Having issues with Angular Material, specifically with mat-list-item and routerLinkActive not functioning as expected

Currently, I am working with a navigation view that utilizes the MatSidenavModule. The issue I am encountering is on mobile screens. When I click a mat-list-item, the mat-sidenav closes as expected. However, upon opening the mat-sidenav again, Material alw ...

Guide to achieving a powerful click similar to a mouse

I've been struggling to get an audio file to play automatically for the past three days, but so far I haven't had any luck. The solutions I've tried didn't work in my browser, even though they worked on CodePen. Can anyone help me make ...

A method for positioning each pair of <li> elements side by side

My goal is to arrange every pair of li elements next to each other (e.g. 0-9, A-B, C-D, ...). Currently, they are aligned one by one. <ul> <li class="alphabetRow"><a href="#" id="alpha_1" class="alphabet active" >0-9</a></li ...

Retrieve the HTML code from a file and store it in a JavaScript variable

My PhoneGap application is able to load an external page in the inAppBrowser and inject a bottom bar onto that page using executeScript(). This allows me to have a bar with basic controls on the specific page. I have successfully implemented this functiona ...

Introducing random special characters into currency symbols during the process of exporting data to a CSV file

I'm encountering a strange issue when exporting data to CSV files that contain a currency symbol. An extra junk character is being added to the data alongside the currency symbol. For example, if my data is: France - Admin Fee 1 x £100 The result I& ...

Is it possible to target an iframe and display text simultaneously?

Trying to create a unique menu that interacts with an iframe and displays text in a separate div upon clicking. Example: • Menu item 1 clicked. • "https://wikipedia.org" loads in the iframe. • Address of the wikipedia page displayed in a diffe ...

Are HTML files and PHP generated files cached differently by web browsers?

My current setup involves Nginx as a web server and Firefox to check response headers. I added two files on the server - test.html and test.php, both containing the same content. In the Nginx config file, I have set the expires directive to 30d in the serv ...

Tips on utilizing Blazorise's numeric edit group with grouping functionality

I recently attempted to utilize the numeric edit group separating attribute in Blazorise but encountered issues. According to the documentation, it should be possible to use this feature, however, my attempts were unsuccessful. I would greatly appreciate ...

Encountering typeahead provider issues when attempting to upgrade UI Bootstrap version from 0.12 to 0.13

After upgrading to ui bootstrap 0.13 to take advantage of the popover template feature, I encountered an error that reads: Unknown provider: $templateRequestProvider <- $templateRequest <- tooltipTemplateTranscludeDirective Unknown provider: $templ ...

The alignment of the timeline in HTML CSS becomes distorted once it reaches the fourth element

As a newcomer to HTML, CSS, and JS, I am currently embarking on the task of creating a personal website for a course project. One of the pages on my website showcases a timeline featuring dates and information. While I have referred to a tutorial on W3scho ...

Links are functional in browsers, but seem to be unresponsive on iPad devices

I'm currently developing a website that allows users to navigate using swipe gestures. Each slide contains multiple links that should redirect users to different locations upon clicking. However, I've encountered a bizarre issue where the links a ...

Scaled-down navigation when scrolling

Is there a way to make the navigation bar shrink when scrolling, similar to how it functions on this website? The transition on this site is so seamless. I'm guessing it's achieved with JQuery. ...