Cordova-plugin-googlemaps: Ionic 2 Custom marker doesn't load from url in android device

Created on 6 Mar 2017  路  5Comments  路  Source: mapsplugin/cordova-plugin-googlemaps

Hello everyone,
Custom marker is not load showing in android device. In iOS is working.
When I get a marker from secure sites (https://) then is worked. But I want to show from without secure site.

Add marker code for android

Custom marker is not shown below code.

 let icon: GoogleMapsMarkerIcon = {
    url: 'http://und.edu/_files/images/cta-homepage-visit.png',
    size: {
      width: 50,
      height: 50
    }
  };
let markerOptions: GoogleMapsMarkerOptions = {
      position: location,
      draggable: false,
      icon: icon
    };

    this.map.addMarker(markerOptions)
      .then((marker: GoogleMapsMarker) => {
    }).catch(err => {})

Custom marker is shown below code.

 let icon: GoogleMapsMarkerIcon = {
    url: 'https://lh4.ggpht.com/Tr5sntMif9qOPrKV_UVl7K8A_V3xQDgA7Sw_qweLUFlg76d_vGFA7q1xIKZ6IcmeGqg=w300',
    size: {
      width: 50,
      height: 50
    }
  };
let markerOptions: GoogleMapsMarkerOptions = {
      position: location,
      draggable: false,
      icon: icon
    };

    this.map.addMarker(markerOptions)
      .then((marker: GoogleMapsMarker) => {
    }).catch(err => {})       .

here only marker url is change. i want to display marker from non secure domain in ionic 2.
note: both demo is working in ios.
please help me
thanks

Most helpful comment

I had the same problem with my phonegap app - turns out that Android image sources must begin "./", as follows:

map.addMarker({
    position: new plugin.google.maps.LatLng( position.coords.latitude, position.coords.longitude ),
    icon: {
        url: './img/mylocation.png'
    }
});

iOS is happy with that too.

All 5 comments

I have no idea.

what about
.catch(err => {})
any errors?

No any errors.
I have debugged your plugin. But couldn't find any solution.
Please update me

I had the same problem with my phonegap app - turns out that Android image sources must begin "./", as follows:

map.addMarker({
    position: new plugin.google.maps.LatLng( position.coords.latitude, position.coords.longitude ),
    icon: {
        url: './img/mylocation.png'
    }
});

iOS is happy with that too.

Please use the plugin v2.

Was this page helpful?
0 / 5 - 0 ratings