1

Is it possible to use an image locally stored on the device as the marker icon? I can use a URL and it works, but when I try to use a local image it won't load. How should I reference the image?

map.addMarker({
    'position': new plugin.google.maps.LatLng(13.7579507,100.5643353),
    'title': 'Fortune Town',
    'icon': 'img/icon.png'
}, function(marker) {
    marker.showInfoWindow();
});

Using Ionic Framework and Cordova with the Google Maps plugin from https://github.com/wf9a5m75/phonegap-googlemaps-plugin/

Already referred to Local image for marker icon on Cordova/Phonegap Google Maps Plugin and tried icon:"www/img/icon.png", but this doesn't work.

Community
  • 1
  • 1
Aishwat Singh
  • 4,331
  • 2
  • 26
  • 48
  • apparently not had the same problem and I had to store my image on a server and occupy it, there I run away. – NHTorres Aug 14 '15 at 17:32

2 Answers2

0

EDIT: Sorry, just noticed that the plugin uses a different api than the JS API of Google maps web version. This answer is therefore not valid. We are successfully using the JS Web version of Google maps in ionic with the code below.


we use this, and it works nicely in all devices we tested and also with ionic serve in the browser.

/www/images is a subfolder of www

 new google.maps.Marker({
      position: thisPos,
      map: $scope.map,
      title: myRequest.title,
      icon: {
          url: 'images/scaled30-' + myRequest.category + '.png',
          size: new google.maps.Size(34, 63),
          scaledSize: new google.maps.Size(34, 63),
          origin: new google.maps.Point(0, 0),
           // The anchor for this image is the base of the tip at 18,63.
           anchor: new google.maps.Size(17, 63)
      },

      request: myRequest
});
Reto
  • 3,107
  • 1
  • 21
  • 33
0

Plugin was written for cordova4 , when running with cordova5 , privateInitialize method is not called properly

some guy Cosmith already fixed that

refer links :

https://github.com/wf9a5m75/phonegap-googlemaps-plugin/issues/537

https://github.com/cosmith/phonegap-googlemaps-plugin#bugfix/icon-crash-cordova-5 --variable API_KEY_FOR_ANDROID="API_KEY" --variable API_KEY_FOR_IOS="API_KEY"

^anyways thanks for help guys

Aishwat Singh
  • 4,331
  • 2
  • 26
  • 48