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 stackoverflow.com/questions/26580937/local-image-for-marker-icon-on-cordova-phonegap-google-maps-plugin and tried icon:"www/img/icon.png" doesn't work (so don't mark it as duplicate plz)
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
});
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