Reputation: 7934
I'm using android maps utils in my project: https://github.com/googlemaps/android-maps-utils
Works fine, but I'm missing one functionality: I need to pick up position by click on map and save location in my local database.
Do you have any idea how to do that? Scenario: new maps activity shown, after user touch on map I need to add marker on touched position and some event containing coordinates to be able to process them.
Upvotes: 0
Views: 1413
Reputation: 3348
Try this,
googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng point) {
Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), getResources().getIdentifier(getResources().getResourceName(R.drawable.pin), "drawable", getPackageName()));
Bitmap resizedBitmap = Bitmap.createScaledBitmap(imageBitmap, 38, 38, false);
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(point.latitude, point.longitude))
.anchor(0.5f, 0.1f)
.title("")
.snippet("")
.icon(BitmapDescriptorFactory.fromBitmap(resizedBitmap)));
}
}
});
Upvotes: 2