Reputation: 554
I am trying to get a drawable id using R.drawable.mapPersonMarker
These are the import statements:
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
and this is the method I am accessing it from:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleMap.OnMapLongClickListener {
public void centreOnLoc(Location location, String title) {
LatLng userLatLng = new LatLng(location.getLatitude(), location.getLongitude());
mMap.clear();
mMap.addMarker(new MarkerOptions().position(userLatLng).title(title).icon(R.drawable.mapPersonMarker));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(userLatLng, 18));
}
Upvotes: 0
Views: 33
Reputation: 554
Found the problem: The drawable resource name was "mapPersonMarker". File-based resource names must contain only lowercase a-z, 0-9, or underscore. Renaming the file to mappersonmarker fixed the issue.
Upvotes: 1
Reputation: 126
Try to use BitmapDescriptorFactory.fromResource(R.drawable.mapPersonMarker).
mMap.addMarker(new MarkerOptions().position(userLatLng).title(title).icon(BitmapDescriptorFactory.fromResource(R.drawable.mapPersonMarker)));
Upvotes: 0