Marker's icon on google map


When I try to set a Icon image to a new marker I get this error:
“Cannot read property android of null…”

this is the code

  var marker = new mapsModule.Marker();
    var icon = new imageModule();
   icon.imageSource = imageSource.fromResource('~/images/map/marker/markerFood.png');
    marker.position = mapsModule.Position.positionFromLatLng(,res.lng);


Hello Dan,

Here I paste a piece of my code that works properly, although seems very similar to your.

let home = new Image();
home.imageSource = imageSource.fromResource( MapUtilService.HOME_ICON );
mapView = this.mapUtilService.getDefaultConfig( mapView );
const marker = this.mapUtilService.createMarker( ...)             
mapView.addMarker( marker );

Create marker contains very simple straight forward code.

       createMarker( mapPoint:any, title:any, index:any, draggable:any, visible:any, icon:any ) {
		var marker:any = new mapModule.Marker();
		marker.position = mapPoint;
		marker.title = title;
		marker.draggable = draggable;
		marker.visible = visible;
		marker.userData = { index : index };

		if ( icon ) {
			marker.icon = icon;
		return marker;

And finally the method getDefaultConfig returns the map with the some settings preset being either android or ios.
We grab each map differently, but I think due to how the settings are set.
In case of Android we grab it from “mapView.gMap” and on ios we grab it from “mapView.ios”

Hope this throw a light, although your code seems pretty similar.
Pointing a useless difference, we do set up the icon after the position, but do not see how that might affect.


Can you past your code into the map-view.js (into the nativescript-google-map-sdk folder) at line 474? My problem is there…


What would you like to review exactly.
The line is this one.

var androidIcon =;

would you like to see the “value” content? or something else?


I have your exact code, it says that “.android” is not a function :\


noboy has solved this problem?


I have already the issue :\


I could get this working by using the following code (note this applies only if you want to load a marker from a file)!

      marker =new mapsModule.Marker();
      marker.position = position;
      let icon = new Image();
      icon.src = '~/images/apple.png';//This seems to be redundant
      icon.imageSource = imageSource.fromFile('~/images/apple.png');  //This is where you load image from file.




var icon = new Image();
icon.src = '~/images/pin.png';
icon.imageSource = imageSource.fromFile('~/images/pin.png');

I’ve end up with the following:

file:///app/studio/location.js:64:25: JS ERROR ReferenceError: Can't find variable: Image

Any ideas on this guys ?
Thank you.

var imgModule = require( "ui/image" );

    let icon = new imgModule.Image();
    icon.src = '~/images/pin.png';
    icon.imageSource = imageSource.fromFile('~/images/pin.png');


will return ;
JS ERROR ReferenceError: Can’t find variable: imageSource


You must find that image-source is also a module from tns-core-module, which you have to import here.


var image-source = require( "image-source" );