ionic-team / ionic-native-google-maps

Google maps plugin for Ionic Native
Other
221 stars 125 forks source link

ionic 4 map working in browser but not in device #not closed #135

Closed ghost closed 5 years ago

ghost commented 5 years ago

I'm submitting a ... (check one with "x")

If you choose 'problem or bug report', please select OS: (check one with "x")

cordova information: (run $> cordova plugin list)

insert the output from the command here

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:

Expected behavior:

Screen capture or video record:

Related code, data or error log (please format your code or data):

The person who share your project files on Github (or other git repository) is in faster lane than other people.
Please share your project files on Github or others(Bitbucket, Gitlabs...etc).
If you don't want to share your project files, please create a demo project, then share it.

Screen captures, and/or native logs(such as Logcat, xcode logs) are appreciate.

Giving much information, you are waiting time is less.
Thank you for your cooperation.

`import { Component, OnInit } from '@angular/core'; import { ToastController, Platform, LoadingController } from '@ionic/angular'; import { GoogleMaps, GoogleMap, GoogleMapsEvent, Marker, GoogleMapsAnimation, MyLocation, BaseArrayClass, ILatLng } from '@ionic-native/google-maps';

@Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage implements OnInit {

map: GoogleMap;

constructor(private platform: Platform) { }

async ngOnInit() { // Since ngOnInit() is executed before deviceready event, // you have to wait the event. await this.platform.ready(); await this.loadMap(); }

loadMap() { let POINTS: BaseArrayClass = new BaseArrayClass([ { position: { lat: 41.79883, lng: 140.75675 }, iconData: "./assets/imgs/Number-1-icon.png" }, { position: { lat: 41.799240000000005, lng: 140.75875000000002 }, iconData: "https://mapsplugin.github.io/ionic-googlemaps-quickdemo-v4/assets/imgs/Number-2-icon.png" }, { position: { lat: 41.797650000000004, lng: 140.75905 }, iconData: { url: "https://mapsplugin.github.io/ionic-googlemaps-quickdemo-v4/assets/imgs/Number-3-icon.png", size: { width: 24, height: 24 } } }, { position: { lat: 41.79637, lng: 140.76018000000002 }, title: "4", iconData: "blue" }, { position: { lat: 41.79567, lng: 140.75845 }, title: "5", iconData: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAACVUlEQVRIS8WWjVXCMBRGwwTqBMIEuAG4ARuIE6gTKBOgEyAT4AbABjKBMIE/C+h3m6S2pWlJ8BzfOTkpad6770teEzom3bZy/VbrpYTopDjJZ6w2c77X6p9j46SCUXvuYDxHq04BZ2rPHXa3y/DRqlPAmdqZW+hrkMZEq44F52q3oGTdrjEpqmPBudoxKVBVKqsU1THgPbW+klNUt4GHCn6idqEGuMveerUeXFGtNTCvah9qaz+n2gMmKMGBnLrfjPFcMirZ7231XUF19RUJkIhPZqXnT8AM9Osy62v0VPihUqIfjWwx1RkJvbxIpjArhabfbEJ6zQYwysiiT3CW8kJ6Q4BgqMALEnqVNAqQZGSkM/R7nMOBLhZ/B/ZQeg9V/1EsrpLy5dIqP8aAXV6WlQIlZrWq/wzeBK0DM3Y0vA0aAh8FPwTaBC7B2W8+qUOMT4l9dYUUrJK2k4tCOHl7O7zK+Xx69nbWU/iebgKz1+9E+OYPToR1fqOe+SquujeBWdzlYGBPohhjW9b2lGbRa72bwLdyml5d2auvaPyeTOzIw4MxzCkal8h8no3cqT3WJd0ExuFmOjXmlhRIXbnfKZQ7hfJ4HDTM8wVIMi6xJ01y3mV8E5glGlDRGIEKS75DrAtFn/0DA3x/b0ddZbPgGt23JnBW0agpKPzUGCvhoT4iv1HG9Zodtc6HGBTYnoXAXc3UR5SbBwK1d8y+8RUAzxNwU2orOwQeyolF/lLT7mUqQ8BqCj4Bt+j1lR0Cs3Sopt8GFLYNF/2JU7K2k6stePL7fwP/AER2xy+mY1/QAAAAAElFTkSuQmCC" }/, { title: "6", position: {lat:41.794470000000004, lng:140.75714000000002}, iconData: window.location.href.replace(/\/([^\/]+)$/, "") + "/../images/number-6-icon.png" }, { position: {lat:41.795010000000005, lng:140.75611}, iconData: "cdvfile://" // The cdvfile:// protocol is acceptable. }, { position: {lat:41.79477000000001, lng:140.75484}, iconData: "file://" // The file:// protocol is also acceptable. }, { position: {lat:41.79576, lng:140.75475}, iconData: "/path/to/image/file" // Absolute path is also acceptable. } / ]);

let bounds: ILatLng[] = POINTS.map((data: any, idx: number) => {
  console.log(data);
  return data.position;
});

this.map = GoogleMaps.create('map_canvas', {
  camera: {
    target: bounds
  }
});
POINTS.forEach((data: any) => {
  data.disableAutoPan = true;
  let marker: Marker = this.map.addMarkerSync(data);
  marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe(this.onMarkerClick);
  marker.on(GoogleMapsEvent.INFO_CLICK).subscribe(this.onMarkerClick);
});

}

onMarkerClick(params: any) { let marker: Marker = params[1]; let iconData: any = marker.get('iconData'); marker.setIcon(iconData); } } `

ionic CLI 4.5.0 Node: 10.14.1 Angular CLI: 7.0.7 OS: win32 x64 typescript 3.1.6

this runs perfect in browser but not in android

wf9a5m75 commented 5 years ago

Duplicated.https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/2514

ghost commented 5 years ago

screenshot_2018-12-01-12-43-10-940_io ionic starter

this is showed in device and followed by browser .. screenshot-192 168 1 16-8100-2018 12 01-12-46-56