Animate Marker Change Position in Xamarin.Android Google Maps - android

I am trying to animate change marker position in Xamarin android Google Map
var markerWithIcon = new MarkerOptions();
markerWithIcon.SetPosition(new LatLng(e.Latitude, e.Longitude));
var marker = googleMap.AddMarker(markerWithIcon);
Setting its position
marker.Position = new LatLng(e.Latitude, e.Longitude);
How to change position with linear animation? Thanks in advance.

Related

How to set margins for IconGenerator in Google Map utils?

I been using google map utils for a couple of days now and it seemed so fine.
This is code im using to add a marker with a custom layout file to the map.
IconGenerator mIconGenerator = new IconGenerator(getApplicationContext());
View mView = getLayoutInflater().inflate(R.layout.map_location_label, null);
TextView mInfoWindowText = (TextView) mView.findViewById(R.id.location);
mInfoWindowText.setText(Takzy.pickupLocationText);
mIconGenerator.setContentView(mView);
mIconGenerator.setRotation(-90);
mIconGenerator.setContentRotation(90);
mIconGenerator.setContentPadding(0, 0, 0, 0);
view.Bitmap mBitmapPickupLocation = mIconGenerator.makeIcon();
Bitmap mBitmapDestinationLocation = mIconGenerator.makeIcon(Takzy.destinationLocationText + " >");
// add the pickup marker to map
mMap.addMarker(
new MarkerOptions().title(Takzy.pickupLocationText)
.position(Takzy.pickupLatLng)
.icon(BitmapDescriptorFactory
.fromBitmap(mBitmapPickupLocation))
.anchor(mIconGenerator.getAnchorU(), mIconGenerator.getAnchorV()));
Everything is okay but as you can see, my text gets cut from the marker label. I have tried googling, read the docs over and over, and none of them worked.
it will work fine if I do not rotate the marker. but I need my marker rotated.
Can someone point out what might be the issue is?

android: google map api always starts showing from africa

I am using a map fragment to show a map. But when the map starte it shows some location in africa and then shifts to the place i wanted. i have tried few solutions in the stackoverflow, which didnt work, it still starts from africa
CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(26.588527, 77.519531));
CameraUpdate zoom = CameraUpdateFactory.zoomTo(4);
mMap.moveCamera(center);
mMap.animateCamera(zoom);
another solution:
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(26.588527, 77.519531), 4));
You can configure initial map state:
using cameraTargetLat, cameraTargetLng, cameraZoom XML attributes, e.g.:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="26.588527"
map:cameraTargetLng="77.519531"
map:cameraZoom="4"/>
programmatically using GoogleMapOptions, e.g.:
CameraPosition indiaPosition = new CameraPosition.Builder()
.target(new LatLng(26.588527, 77.519531))
.zoom(4)
.build();
GoogleMapOptions mapOptions = new GoogleMapOptions().camera(camera)
SupportMapFragment map = SupportMapFragment.newInstance(mapOptions);
Try this:
//setting India region in google maps
LatLngBounds INDIA = new LatLngBounds(
new LatLng(7.2, 67.8), new LatLng(36.5, 93.8));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(INDIA.getCenter(), 5));
this would set India region on the map.
Try this :
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(26.588527, 77.519531), 11.5f), 4500, null);
works very well !!

how to use custom pointers in osmdroid?

I am using OSMDroid and this code gives default markers to point my location. How do i put custom markers in place of the default markers? How do i import a new drawable?
anotherOverlayItemArray = new ArrayList<OverlayItem>();
anotherOverlayItemArray.add(new OverlayItem("KTM2", "KTM2", myLocation));
ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new
ItemizedIconOverlay<OverlayItem>( this, anotherOverlayItemArray,myOnItemGestureListener);
mapView.getOverlays().clear();
mapView.getOverlays().add(anotherItemizedIconOverlay);
mapView.invalidate();
You can set a specific marker to each OverlayItem:
OverlayItem item = new OverlayItem("KTM2", "KTM2", myLocation);
Drawable myMarker = getResources().getDrawable(markerResId);
item.setMarker(myMarker);
anotherOverlayItemArray.add(item);
You can also get rid of the ItemizedIconOverlay/OverlayItem approach by using the OSMBonusPack Marker.

how to convert BitmapDescriptor to drawable in android for imageview

Hi i am developing mapview using v2,
From MarkerOptions object i am getting an icon, like...
MarkerOptions mo = markersList.get(pos);
BitmapDescriptor icon = mo.getIcon(); //Gets the custom icon set for this MarkerOptions object.
ImageView logo;
//how to assign icon to textview like using below code
logo.setBackgroundResource(icon) // It is not taking directly (BitmapDescriptor icon)
Please help. Thank you.

MapView, fixed size of OverlayItem drawable

I use osmdroid which is based on Google Map API v1. When I zoom in/out the map my markers are scaling accordingly but I want them to have fixed size. So how can I prevent scaling of a Drawable (used as a marker of OverlayItem) when I zoom in/out the map?
I create Drawable for the marker using BitmapDrawable(scaledBitmap)
for fix size u add a popupview on a geopoint which is fix size by setting view params and set this drawable as a background
View popUp = getLayoutInflater().inflate(R.layout.map_popup, map, false);
MapView map = (MapView) findViewById(R.id.mapview);
MapView.LayoutParams mapParams = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
<geopoint>,
<x offset if required>,
<y offset like pinHeight>,
MapView.LayoutParams.BOTTOM_CENTER);
map.addView(popUp, mapParams);

Categories

Resources