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);
Related
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?
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.
I need to add icon to my map, something like image below :
this is my code :
MarkerOptions marker = new MarkerOptions().position(location).title("resturan")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.a2));
I manage to add icon to my map but it's just an icon with no border and it doesn't look nice , in the above image , there is a border around each image , this is what i need
How can I add this border to my icons ?
thank you
Take a look at this blog post I wrote on how to put images inside the InfoWindow in an asynchronous way:
Guide: Google Maps V2 for Android : Update InfoWindow with an Image Asynchronously
You can see there how to specify a layout for your InfoWindow as well, in the layout you could add the borders to your image using the margins attribute.
This way you can customize your map icon before apply in the map.
public Bitmap createDrawableFromView(Context context) {
View marker = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).
inflate(R.layout.map_popup, your_parent_layout,false);
TextView tv_location_name = (TextView) marker.findViewById(R.id.tv_location_name);
TextView tv_event_status = (TextView) marker.findViewById(R.id.tv_event_status);
TextView tv_event_name = (TextView) marker.findViewById(R.id.tv_event_name);
DisplayMetrics displayMetrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
marker.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
marker.layout(0, 0, displayMetrics.widthPixels, displayMetrics.heightPixels);
marker.buildDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(marker.getMeasuredWidth(), marker.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
marker.draw(canvas);
return bitmap;
}
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.
LinearLayout maplayout = new LinearLayout(this);
maplayout.setGravity(Gravity.BOTTOM);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,600);
MapView mapView = new MapView(this,mapkey);
MapController mc = mapView.getController();
mc.setZoom(20);
maplayout.addView(mapView,params);
setContentView(maplayout);
I got a mapview with a specified location by using the above code and its run successfully but
When i swipe in map it doesnt move.. its APK level 8 project
Add this to your mapview in xml,
android:clickable="true"
Or, Add this in your Java file,
mapView.setClickable(true);