Nullpointerexception Whilst Trying To Add Polyline/marker To A Googlemap
I have a SupportMapFragment with a GoogleMap object (which I have manipulated already using a GoogleMapOptions) and it is displaying/functioning fine, until I call getMap().addPoly
Solution 1:
If you add the SupportMapFragment to the layout file you don't have to create a new instance manually. You just need to obtain the reference by calling
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap map = mapFragment.getMap();
You are probably getting the NPE because the newly instantiated fragment haven't created the GoogleMap object yet.
Post a Comment for "Nullpointerexception Whilst Trying To Add Polyline/marker To A Googlemap"