Closed loicparent closed 2 years ago
I tried with a new blank project and this is the result of the command ionic info:
Ionic:
Ionic CLI : 6.18.1 (/Users/myusername/.nvm/versions/node/v14.15.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 6.1.5
@angular-devkit/build-angular : 13.2.6
@angular-devkit/schematics : 13.2.6
@angular/cli : 13.2.6
@ionic/angular-toolkit : 6.1.0
Capacitor:
Capacitor CLI : 3.5.1
@capacitor/android : 3.5.1
@capacitor/core : 3.5.1
@capacitor/ios : 3.5.1
Utility:
cordova-res : 0.15.4
native-run : 1.5.0
System:
NodeJS : v14.15.0 (/Users/myusername/.nvm/versions/node/v14.15.0/bin/node)
npm : 6.14.8
OS : macOS Monterey
I don't see any obvious mistake here. You do have node v14 installed, you could try and install v16 and see if it works then. It's also wise to take a look at the troubleshooting guide by Capacitor themselves: https://capacitorjs.com/docs/android/troubleshooting
Otherwise I would kindly ask you to share a reproduction (as barebones as possible), so that I can take a look at it.
@loicparent I don't see any mistakes, but make sure you have @capacitor-community/google-maps version 2.0.0.beta.x (latest 2.0.0.beta.4)
Also, there're extra steps on iOS. Make sure you had done it. https://capacitor-community.github.io/google-maps/#/getting-started/installation?id=ios
Hello @tafelnl & @va2ron1,
Thanks for your replies :)
I just tried with the beta.4 instead of the beta.1 but I don't see any changes. The map doesn't appears and the error in the console is still visible.
I have followed the installation documentation and so change the configuration in xCode to use the CustomMapViewController
instead of the CAPBridgeViewController
.
You can find here the basic reproduction of my code. (You'll just have to change the API key in the file home.page.ts:15
)
@loicparent I didn't realize it but you're creating wrong the map. It should be something like this. The element parameter isn't implemented yet.
...
let result = await CapacitorGoogleMaps.createMap({
boundingRect: {
width: Math.round(boundingRect.width),
height: Math.round(boundingRect.height),
x: Math.round(boundingRect.x),
y: Math.round(boundingRect.y),
},
cameraPosition: {}
});
...
Also two things not related to this plugin:
Hello @va2ron1,
Thanks for your help!
I just tried but I don't see any changes. The map doesn't appears and the error in the console is still visible. (There is just the boundingRect (without round) that change).
When I inspect the render in the simulator using the console, I see that the size of the map takes up all the space with the value 100%. I tried also with viewport value (vw, vh) but no changes too.
So the map element stay empty with an error in the console.
@loicparent This notes is from a repository that I cloned in order to see and fix your problem. I pushed the changes here
@va2ron1 Thank you very much for helping out! Much appreciated. @loicparent Can you let us know if this solved it for you?
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:
ion-content {
--background: transparent;
}
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:
let result = await CapacitorGoogleMaps.createMap({
boundingRect: {
width: Math.round(boundingRect.width),
height: Math.round(boundingRect.height),
x: Math.round(boundingRect.x),
y: Math.round(boundingRect.y),
},
cameraPosition: {
target: {
latitude: 33.6,
longitude: -117.9
}
}
});
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
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
Describe 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 functionpostToNative
in the main functionnativeBridge
.To Reproduce Steps to reproduce the behavior:
@capacitor-community/google-maps
ionic cap run ios --open
and then, open the simulator.Expected behavior The map should appears without error in the console.
Thanks for your help, Loïc
Screenshots
HTML
SCSS
TypeScript Code