Closed almaz1213 closed 3 years ago
API key has no any restriction
Please share your project files on github. Information is too less.
$ ionic info
Ionic:
Ionic CLI : 6.13.1 (/home/diamo/.nvm/versions/node/v12.16.3/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 5.0.4 @angular-devkit/build-angular : 0.900.4 @angular-devkit/schematics : 8.3.25 @angular/cli : 9.0.4 @ionic/angular-toolkit : 2.2.0
Capacitor:
Capacitor CLI : 2.4.7 @capacitor/core : 2.4.7
Cordova:
Cordova CLI : 10.0.0 Cordova Platforms : 6.0.0, android 9.1.0, browser Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 7 other plugins)
Utility:
cordova-res : 0.15.3 native-run (update available: 1.3.0) : 0.3.0
System:
Android SDK Tools : 26.1.1 (/home/diamo/Android/Sdk) NodeJS : v12.16.3 (/home/diamo/.nvm/versions/node/v12.16.3/bin/node) npm : 6.14.4 OS : Linux 5.4
config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="space.diamo.iol.dinka" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>DinKa</name>
<description>Dates in car</description>
<author email="alik@e-gove.net" href="http://iol.diamo.space">Alik Cagol</author>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="http://172.20.10.3:4210" sessionid="06c8b98e" />
<content original-src="index.html" src="http://172.20.10.3:4210" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="21" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="AIzaSyDLzKyekn********gtrN8pX39awZAjw" />
</widget>
map.component.html:
<ion-header translucent *ngIf="inData?.command !== 'address'">
<ion-toolbar>
<ion-title>{{c.sideDialogs.get(this.dialogKey).title}}<span>. {{c.l.i187}}
: {{radiusTitle}} km</span>
</ion-title>
<ion-buttons slot="end" *ngIf="compMode === 0">
<ion-button (click)="c.closeSideDialog(this.dialogKey)">
<ion-icon slot="icon-only" name="close"></ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-searchbar #searchbar *ngIf="inData?.command === 'address'" [placeholder]="c.l.i202" (keyup.enter)="search(searchbar.value)" inputmode="search" type="text" (ionClear)="address = {addr: null, lat: null, lon: null, countryCode: null}">
</ion-searchbar>
<ion-content fullscreen>
<div id="map_canvas"></div>
..........
map.component.ts:
import {Component, Input, ViewChild} from '@angular/core';
import {IonSearchbar} from "@ionic/angular";
import {
GoogleMaps,
GoogleMap,
GoogleMapsEvent,
Geocoder, GeocoderRequest, GeocoderResult,
Marker,
ILatLng, MarkerOptions,
Environment, BaseArrayClass
} from '@ionic-native/google-maps';
import {CommService} from "../comm.service";
import {GeoLoc, InAppProtocol, OrderObserverEvent, Order} from "../interfaces";
import {filter, share} from "rxjs/operators";
@Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss'],
})
export class MapComponent {
@Input() dialogKey: number;
@ViewChild(IonSearchbar) searchbar: IonSearchbar;
private lat: number;
private lon: number;
private zoom = 13;
private radius = 0;
radiusTitle = 0;
inData;
private order: Order;
compMode = 0; //0 - map, 1 - list
private map: GoogleMap;
private meMarker: Marker;
private markers: Record<string, { order: Order, marker: Marker, dist: number }> = {};
private addrFoundByAddress = false;
orderList: {
code: string;
type: number;
nick: string;
gender: number;
img: string;
userId: number;
radius_km?: number;
price_km?: number;
dist: any;
currency?: string;
payCash?: boolean;
paySinhro?: boolean;
payIou?: boolean;
carModel?: string;
carImg?: string;
seats?: number;
}[];
sortBy: string; //dist | price | dont
filter: Record<string, any>;
private tmp;
address = {addr: null, lat: null, lon: null, countryCode: null};
constructor(public c: CommService) {
this.c.inAppCommX.pipe(
filter(d => (d['to'] === 'mapComp' || d['to'] === 'all' && d.hasOwnProperty('command'))),
share()
).subscribe((d: InAppProtocol) => {
if (d.command !== null && d.command in this && typeof this[d.command] == 'function') {
this[d.command](d.data, d.callBack, d.from);
}
});
}
ionViewWillEnter() {
this.inData = this.c.sideDialogs.get(this.dialogKey).inData;
try {
this.order = this.inData.data.order;
} catch (e) {
}
this.lat = this.c.geoLoc.lat;
this.lon = this.c.geoLoc.lon;
if (this.c.platform === 0) { // 0 means browser platform
Environment.setEnv({
API_KEY_FOR_BROWSER_DEBUG: this.c.appConfig.googleMapsJSDebugKey.val,
API_KEY_FOR_BROWSER_RELEASE: this.c.appConfig.googleMapsJSDebugKey.val
})}
let mapOpts = {
camera: {
target: {
lat: this.lat,
lng: this.lon
},
zoom: this.zoom
},
preferences: {
zoom: {
minZoom: 4
}
},
controls: {
compass: false,
myLocationButton: true,
myLocation: true, // (blue dot)
indoorPicker: true,
zoom: false, // android only
mapToolbar: false // android only
},
styles: [
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{"visibility": "off"}
]
}
],
gestures: {
scroll: true,
tilt: true,
zoom: true,
rotate: true
}
}
if (this.inData.command === 'watch') {
this.zoom = 16;
mapOpts.camera.zoom = 16;
}
if (this.inData.command === 'address') {
if (this.inData.hasOwnProperty('data') && this.inData.data.addr) {
this.address = this.inData.data;
}
this.zoom = 18;
mapOpts.camera.zoom = 18;
}
this.map = GoogleMaps.create('map_canvas', mapOpts);
this.map.addEventListener(GoogleMapsEvent.MAP_READY).subscribe(() => {
if (this.inData.command === 'getAddress') {
Geocoder.geocode(this.inData.data)
.then((res: GeocoderResult[]) => {
//console.log('res=', res);
try {
this.address.addr = res[0].extra.lines.join(', ');
this.address.lat = res[0].position.lat;
this.address.lon = res[0].position.lng;
this.address.countryCode = res[0].countryCode;
} catch (e) {
}
this.ok();
})
return;
}
if (this.inData.command === 'watch') {
/*
const ll = this.map.getCameraPosition().target;
this.lat = ll.lat;
this.lon = ll.lng;
this.map.addMarker({
position: {lat: this.lat, lng: this.lon},
icon: {
url: '../../assets/icon/eye.png',
size: {
width: 32,
height: 32
}
},
anchor: [16, 16]
})
this.setRadiusFromLoc(this.map.getVisibleRegion().southwest, this.map.getVisibleRegion().northeast);
*/
console.debug('map radius changed:', this.radius);
this.order.jobRadius = this.radius;
/*
this.c.be.setOrderLoc(this.order.code, [this.lat, this.lon], d => {
if (d && !d.hasOwnProperty('err')) {
this.c.be.observeMatchedOrders(this.order.code, true, this.order.jobRadius, this.matchedOrderObserver);
}
});
*/
console.debug('map center changed in map init:');
}
if (this.inData.command === 'order') {
this.map.addMarker({
position: {lat: this.lat, lng: this.lon},
icon: {
url: '../../assets/icon/cross32.png',
size: {
width: 19,
height: 19
}
},
anchor: [9, 9]
}).then((m: Marker) => {
this.meMarker = m
})
if (this.order.type === 1) {
this.setRadiusFromLoc(this.map.getVisibleRegion().southwest, this.map.getVisibleRegion().northeast);
this.order.jobRadius = this.radius;
} else {
this.order.jobRadius = this.order.fields.radius_km;
this.radius = this.order.jobRadius;
this.radiusTitle = Math.round(this.radius * 100) / 100;
}
this.c.be.setOrderLoc(this.order.code, [this.lat, this.lon], d => {
if (d && !d.hasOwnProperty('err')) {
this.c.be.observeMatchedOrders(this.order.code, true, this.order.jobRadius, this.matchedOrderObserver);
}
});
}
if (this.inData.command === 'address') {
if (this.address.lat && this.address.lon) {
this.addrFoundByAddress = true;
this.map.animateCamera({
target: {lat: this.address.lat, lng: this.address.lon},
zoom: 19,
duration: 3000
})
}
this.searchbar.setFocus();
}
});
this.map.on(GoogleMapsEvent.CAMERA_MOVE_END).subscribe(d => {
if (this.inData.command === 'watch') {
const ll = this.map.getCameraTarget();
if (this.lat !== ll.lat || this.lon !== ll.lng) {
this.lat = ll.lat;
this.lon = ll.lng;
this.c.be.setOrderLoc(this.order.code, [this.lat, this.lon]);
this.recalcMarkerDists();
console.debug('map center changed:', ll);
}
if (this.zoom !== d[0].zoom) {
this.zoom = d[0].zoom;
this.setRadiusFromLoc(this.map.getVisibleRegion().southwest, this.map.getVisibleRegion().northeast);
this.order.jobRadius = this.radius;
this.c.be.observeMatchedOrders(this.order.code, true, this.order.jobRadius, this.matchedOrderObserver);
console.debug('map radius changed:', this.radius, d);
}
}
});
this.map.on(GoogleMapsEvent.MAP_DRAG_END).subscribe(d => {
if (this.addrFoundByAddress) {
this.address.addr = null;
this.address.lat = null;
this.address.lon = null;
this.address.countryCode = null;
this.addrFoundByAddress = false;
this.searchbar.value = null;
}
})
//this.test();
}
........
variables.gradle:
ext {
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
androidxAppCompatVersion = '1.1.0'
androidxCoreVersion = '1.2.0'
androidxMaterialVersion = '1.1.0-rc02'
androidxBrowserVersion = '1.2.0'
androidxLocalbroadcastmanagerVersion = '1.0.0'
androidxExifInterfaceVersion = '1.2.0'
firebaseMessagingVersion = '20.1.2'
playServicesLocationVersion = '17.0.0'
junitVersion = '4.12'
androidxJunitVersion = '1.1.1'
androidxEspressoCoreVersion = '3.2.0'
cordovaAndroidVersion = '7.0.0'
}
Oh, my...
Thanks, but I prefer the files share to reproduce your problem.
Did you find out which code cause the error?
i think problem is not in my code. i just did npm install --save git://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps and rebuilt.
android studio build log now shows:
/home/diamo/eclipse_ws/DinKa/bridle/android/capacitor-cordova-android-plugins/src/main/java/plugin/google/maps/PluginPolyline.java:6: error: package com.google.android.libraries.maps.model does not exist
import com.google.android.libraries.maps.model.CircleOptions;
^
/home/diamo/eclipse_ws/DinKa/bridle/android/capacitor-cordova-android-plugins/src/main/java/plugin/google/maps/PluginPolyline.java:7: error: package com.google.android.libraries.maps.model does not exist
import com.google.android.libraries.maps.model.LatLng;
^
/home/diamo/eclipse_ws/DinKa/bridle/android/capacitor-cordova-android-plugins/src/main/java/plugin/google/maps/PluginPolyline.java:8: error: package com.google.android.libraries.maps.model does not exist
import com.google.android.libraries.maps.model.LatLngBounds;
^
/home/diamo/eclipse_ws/DinKa/bridle/android/capacitor-cordova-android-plugins/src/main/java/plugin/google/maps/PluginPolyline.java:9: error: package com.google.android.libraries.maps.model does not exist
import com.google.android.libraries.maps.model.MarkerOptions;
^
/home/diamo/eclipse_ws/DinKa/bridle/android/capacitor-cordova-android-plugins/src/main/java/plugin/google/maps/PluginPolyline.java:10: error: package com.google.android.libraries.maps.model does not exist
import com.google.android.libraries.maps.model.Polyline;
^
/home/diamo/eclipse_ws/DinKa/bridle/android/capacitor-cordova-android-plugins/src/main/java/plugin/google/maps/PluginPolyline.java:11: error: package com.google.android.libraries.maps.model does not exist
import com.google.android.libraries.maps.model.PolylineOptions;
^
Please try to set AndroidX=True
already mate. yesterday
also, in package.json:
"cordova-plugin-androidx": "^3.0.0",
"cordova-plugin-androidx-adapter": "^1.1.3",
android.enableJetifier=true is set, too
i reinstalled all acording documentations and now in android studio:
.....
04-25 03:36:30.801 3621-3621/space.diamo.iol.dinka D/Capacitor/Console: File: http://localhost/main-es5.js - Line 1098 - Msg: Gonna show dialog: MapComponent key=1619296590800
04-25 03:36:30.807 3621-3680/space.diamo.iol.dinka D/Capacitor: Handling local request: http://localhost/39-es5.js
04-25 03:36:30.830 3621-3680/space.diamo.iol.dinka D/Capacitor: Handling local request: http://localhost/11-es5.js
04-25 03:36:30.860 3621-3621/space.diamo.iol.dinka W/Capacitor/Console: File: http://localhost/main-es5.js - Line 1111 - Msg: ac create sideDialogs amount: 1
04-25 03:36:30.927 3621-3621/space.diamo.iol.dinka W/Capacitor/Console: File: http://localhost/vendor-es5.js - Line 128859 - Msg: Native: tried accessing the GoogleMaps plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
04-25 03:36:30.929 3621-3621/space.diamo.iol.dinka E/Capacitor/Console: File: http://localhost/vendor-es5.js - Line 18589 - Msg: ERROR
.......
Please share your project files on github. Information is too less.
i shared the project. confirm the invitation plz
after reinstallation ionic capacitor device.getinfo returns web platform on android device. oghh.......
Oh, this plugin doesn't support capacitor yet
ok. it means there iz pleace to grow up for u )
The next version supports capacitor platform, but it's still under development
ok. nice. i 'll use js version so far. u also consider including openmap/street plugin. all the best
development/project management is getting worse
since significant changes in cordova's last versions it makes a lot problems for use your awesome plugin. you should implement it in as capacitor native plugin. wish u all the best with that. i'm closing this issue so far
I'm submitting a ... (check one with "x")
OS: (check one with "x")
cordova information: (run
$> cordova plugin list
)If you use
@ionic-native/google-maps
, please tell the package.json (only@ionic-native/core
and@ionic-native/google-maps
are fine mostly)Current behavior: the plugin works when i use it in browser platform, but does not in android: the map does not appear
in AVD:
in browser:
Expected behavior: should work as in browser platform
Related code, data or error log (please format your code or data):