How to integrate ion-cards and ion-slides over a Google Map in an Ionic mobile application

I'm currently in the process of developing a hybrid mobile application using Ionic. One aspect of the app involves incorporating swipe-able cards on top of a map, similar to the layout seen in the TripAdvisor app. As a newcomer to this technology, I'm facing some challenges with implementing this feature.

Take a look at the TripAdvisor example

To achieve this design, I am utilizing Angular Google Maps for the map display within an <agm-map> element. Additionally, I am employing Ionic's ion-slides element along with ion-card in each ion-slide to create the sliding cards effect. My goal is to have the map occupy the entire content area while having the slides positioned on top of it. Although I have managed to display the map and slides below it, I'm encountering difficulties in overlaying them. I experimented with different positioning techniques as suggested in this resource: Guide on floating a div over Google Maps, but these attempts either distort the card dimensions or cause the map to disappear entirely.

While I attempted to replicate the issue on stackblitz, I encountered difficulty loading the map. Nonetheless, I will provide the code snippet for reference (please ensure to add your own Google Maps API key in app.module.ts) View the code here

Any assistance or guidance would be greatly appreciated. Given my limited experience in this field, I am eager to learn and improve!

home.html code:

<ion-header>
  <ion-navbar>
    <ion-title>
      Slides Overlay
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content>
    <agm-map [latitude]="51.507692" [longitude]="-0.127718">
    </agm-map>
      <ion-slides loop centeredSlides slidesPerView="auto">
        <ion-slide *ngFor="let slide of scenes; let i = index">
          <ion-card>
            <img [src]="cat" class="slide-image">
            <ion-card-content>
              <h2>
                Heading {{i}}
              </h2>
              <h3>Sub-heading {{i}}</h3>
            </ion-card-content>
          </ion-card>
        </ion-slide>
      </ion-slides>
</ion-content>

home.scss code:

page-home {

 agm-map {
        height: 100%;
        }

        .swiper-slide{
        width: 70% !important;
    }

    .slide-image {
        height: 100px;
        width: 100%;
        object-fit: cover;
    }

        ion-card {
        height: 160px;
    }

    ion-card-content, .card-content-md{
        text-align: left;
        padding: 0 0 0 3px;
    }
}

Answer №1

Here is my final solution: I set the map to be 100% height and applied a negative top margin to the ion-slides component:

    agm-map {
        height: 100%;
    }
    ion-slides {
        height: 175px;
        margin-top: -175px;
    }

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

Issues with CSS media queries not being responsive in Safari

Can anyone shed light on why media queries are not functioning properly in Safari? Here is an example: body { background-color:black; } @media screen and (min-width: 1024px) and (max-width: 1300px) { body { background-color:red; } } ...

The background image on a lengthy HTML table goes missing

Within a table cell, I have around 7500 short text lines. Interestingly, the background image of the table disappears around the 1800th line. I'm wondering if there is a specific limit on the length of the table that could be causing this? Even ...

Having trouble creating two bar charts with different data sets in ng2-charts using Angular 8

I attempted to display two charts simultaneously on a single page by utilizing the following code in HTTP: <div class="chk-block-content"> <canvas height="100" width="500" baseChart [datasets]="barChartData" [labels]="barChartLabels" [options ...

How can I adjust the height and width of a checkbox input specifically for mobile screens?

Check out this code snippet: <div class="container-fluid mt-5"> <div class="row"> <div class="col-10"> Hello <br> Hello </div> <div class="col-2"> <input type="checkbox" class= ...

Having trouble with your jQuery animation on a div?

Check out this jsFiddle example: http://jsfiddle.net/uM68j/ After clicking on one of the links in the demo, the bar is supposed to smoothly slide to the top. However, instead of animating, it immediately jumps to the top. How can I modify the code to ac ...

Error message: The subFn function in the Angular-Calendar is not a

I am facing difficulties with the angular 5 calendar component located at The calendar displays correctly, including events etc. However, when trying to use the mwlCalendarPreviousView and mwlCalendarNextView directives, they do not seem to work. Upon cl ...

Class remains unaffected by media query modification

With Bootstrap5 in play and an additional stylesheet added as the last one in the lineup, my goal is to customize the margins of the .content class. The snippet of code below resides at the end of my stylesheet... .content { width: 100vw; m ...

Tips for adjusting the size of an image to fit within the page layout alongside navigation bars

I am currently working on adjusting the size of my image to fit on the page without requiring a scroll. It appears that the jumbotron and navigation elements are causing the image to be pushed down. To address this issue, I thought about placing the image ...

What is the reason that root elements of stacking contexts do not stack when their properties are different?

Today, I encountered a surprising scenario where an element with a transform property that was not set to none failed to stack above another element with a position of absolute, despite having a higher z-index. However, adding either position:absolute or p ...

Adjust the state based on the event in ReactJs

I have the following code snippet in a React JS application: const items = [ { value: "A", label: "A" }, { value: "B", label: "B" }, { value: "C", label: "C" }, { value: "D", label: "D" }, { value: " ...

Shifting an icon to the left with CSS

.panel { margin-bottom: 20px; background-color: #F7FAFE; border: 1px solid transparent; border-radius: 4px; -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05); box-shadow: 0 1px 1px rgba(0, 0, 0, .05) } .panel-default { padding: 1 ...

I'm attempting to include a home glyphicon in my navigation bar using a bootstrap class. Unfortunately, it doesn't appear on the output page. Any suggestions for resolving this issue?

I'm having trouble adding a home icon using Bootstrap glyphicon; it's not appearing in the output. Can someone assist me with this? I've already attempted to increase the font size and change the font color, but neither solution worked. &l ...

Ways to customize easypiechart appearance with CSS styling

I am looking to create a circular counter similar to the one shown below. I have tried using easy-pie-chart but I am unsure how to style the circles to look like the example provided. Is there a way to achieve this through CSS? Any recommended resources o ...

Utilizing background styles for enhancing the appearance of Ionic side menus

I've been experimenting with ionic and angular.js, trying to figure out the best way to apply background styles to side menus. I currently have a blurred background image with content boxes placed on top of it. My goal is to keep the background fixed ...

Why am I receiving a 404 error when trying to access an Angular 9 route within a subfolder

I am facing an issue with my Angular 9 app that is hosted in a domain subfolder. The problem lies in the index.html base tag, shown below: <base href="/subfolder/"> Everything works perfectly fine when the app is run locally without the ba ...

"NgFor can only bind to Array objects - troubleshoot and resolve this error

Recently, I've encountered a perplexing error that has left me stumped. Can anyone offer guidance on how to resolve this issue? ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supp ...

Are there any user interface frameworks available that can replicate the aesthetic of a Mac application?

I've been searching high and low but I haven't come across any answers yet. It caught my attention that the wunderlist mac app was developed using HTML/CSS/JS, but I'm curious if they incorporated a pre-existing UI JavaScript framework into ...

Creating a Dropdown Menu: Connecting Multiple Buttons to a JavaScript Function

I am currently working on creating a dropdown menu. I have already written the HTML and Javascript for two buttons, but I'm not sure how to connect the second button to the Javascript function. Do I need to write another function()? <div class="dr ...

Leverage one Injectable service within another Injectable service in Angular 5

I am facing difficulties in utilizing an Injectable service within another Injectable service in Angular 5. Below is my crudService.ts file: import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; ...

How to eliminate arrows in ngx-bootstrap datepicker?

I recently started working with Angular and Bootstrap and I'm facing an issue. I am using a ngx bootstrap datepicker, but I would like to remove the standard arrows on the buttons of the datepicker calendar. Here is a screenshot of the problem: https ...