The map does not appear (or is empty)
See original GitHub issueDescribe the bug
The map is not shown in browser, simulator or native device.
I see an error in the console of the simulator:
Unhandled Promise Rejection: DataCloneError: The object can not be cloned.
from the function postToNative
in the main function nativeBridge
.
To Reproduce Steps to reproduce the behavior:
- Install a fresh version of Ionic with Capacitor
- Install the plugin
@capacitor-community/google-maps
- Configure the plugin as indicated in the official doc
- Launch the function
ionic cap run ios --open
and then, open the simulator. - In the simulator the map does not appears.
- Open the console to see the error.
Expected behavior The map should appears without error in the console.
Thanks for your help, Loïc
Screenshots
HTML
<ion-content [fullscreen]="true">
<div id="map" #map></div>
</ion-content>
SCSS
#map {
width: 100%;
height: 100%;
}
TypeScript Code
import { Component, ElementRef, ViewChild } from '@angular/core';
import { CapacitorGoogleMaps } from "@capacitor-community/google-maps";
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
@ViewChild('map') mapView: ElementRef;
constructor() {
CapacitorGoogleMaps.initialize({
key: "MY-API-KEY",
devicePixelRatio: window.devicePixelRatio
});
}
ionViewDidEnter() {
this.createMap();
}
async createMap() {
const element = this.mapView.nativeElement;
const boundingRect = element.getBoundingClientRect() as DOMRect;
let result = await CapacitorGoogleMaps.createMap({
element: element,
boundingRect: boundingRect,
cameraPosition: {
target: {
latitude: 33.6,
longitude: -117.9
}
}
});
element.style.background = "";
element.setAttribute("map", result.googleMap.mapId);
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
How to check if a Map or Set is empty? - javascript
Show activity on this post. For both cases you can use const populatedSet = new Set(['foo']); console.log(populatedSet.size); // should be 1.
Read more >Map does not display in Layout - ArcGIS Pro 3 - Esri Community
Map frame is blank in layout. The data is visible in the map view but when I add the map frame to the...
Read more >Apple Photos "Places" map is empty, despi…
After upgrading to Catalina, Apple Photos "Places", which views photos by geotag on a map, is empty (shows no photos, just an empty...
Read more >Empty places with no information show up in google maps
I see one place in google maps which has the green i-want-to-go-there-marker, but when i click it, it comes up empty, it doesn't...
Read more >Map visualization does not show and blank
Map visualization does not work, only showing white blank (second picture below). I have clear cache. I have enalabled map (in admin portal, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
But please use the search function / discussions / Stack Overflow for these kind of questions so we can keep everything organized 😃
Closing this issue since it’s solved now
Hello,
Many thanks for your help @va2ron1!
Ok so after comparing and testing, there are 2 things that was wrong.
First, I didn’t use the css variable to set transparency to the ion-content. So use the css variable instead of the property is ok:
Second, the console error related to the cloned element is due to the fact that I had the key
element
in the “CreateMapOptions” object. So when I remove the key, this is ok:So now, this is ok and I have updated the repository here.
I have an additional question: Is it possible to show the map in a modal and having multiple map instances?
Thanks again 😃 Loïc