google map v2 issue with uft8 string for title in android - android

I'm developing an android project,in this project i have google map view and i use google map v2 . The problem is, i have some MarkerOption and i'm setting a utf8 string for them but the titles are shown as an empty string
here is my code for adding markers:
MarkerOptions marker = new MarkerOptions().position(pos).title("سلام");
marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
googleMap.addMarker(marker);
how can i solve this?
thanks for any helps

you must set an English word then set your string :
MarkerOptions marker = new MarkerOptions().position(pos).title("TEST:"+"سلام");

You can add a unicode left-to-right mark ("\u200e") to your text, like:
.title("\u200e" + "سلام");

Related

If I don't want cluster marker on here map, what shoud I do ? Please

I'm trying show all my map makers on Here maps, but I don't want cluster them to a number, like image. I used Here maps app, markers not clustered Here Maps.
What should I do ?.
You can find information about it here.
You can use the ClusterLayer class.
ClusterLayer cl = new ClusterLayer();
If you want to customize the image use their ImageClusterStyle & ClusterTheme.
ImageClusterStyle imageCluster = new ImageClusterStyle(img);
ClusterTheme theme = new ClusterTheme();
theme.setStyleForDensityRange(2, 9, imageCluster);
cl.setTheme(theme);

Android google maps marker disable navigation option

Im creating an app where users need to walk to a point on a map. But they need to find a route to the point by them selves.
Ive created a map with markers but by default if a user clicks on the marker a "start navigation" and "view in google maps" option is shown. Is it possible to disable these options ?
The options that are shown on marker click
This thing is called Map Toolbar. You can disable it by calling UiSettings.setMapToolbarEnabled(false):
GoogleMap map;
....... //init map
map.getUiSettings().setMapToolbarEnabled(false);
You can also define setMapToolbarEnabled() from the XML using the following property:
map:uiMapToolbar="false"
In kotlin you can do:
map.apply {
uiSettings.isMapToolbarEnabled = false
}
If anyone needs to do this in Google Maps v2, you set it in the map options instead of setting it on the map directly. So like this:
var mapOptions = new GoogleMapOptions().InvokeMapToolbarEnabled(false);

Google maps V2 marker's title in other languages

I want to show a marker on Google Maps API V2:
this is my code:
driverMarker = new MarkerOptions();
driverMarker.icon(BitmapDescriptorFactory.fromResource(R.drawable.driver_car));
driverMarker.position(driverLocation);
driverMarker.title(getDriver().getName());
googleMap.addMarker(driverMarker);
The driver name is saved in Hebrew, and also my Google maps language is in Hebrew (the street names). However, when my getDriver().getName() returns string in Hebrew it doesn't show me the title (the title is blank as you can see in the screenshot attached). But if the poi.getName() returns string in english it show the title on the marker...
What can I do in order to display Hebrew on the marker's title???
screenshot
You can find the solution here by #Gavriel:
Non-ASCII title for android map marker
In short:
You can use android:textDirection="locale" on TextView in customized InfoWindowAdapter (if you are using api 17 and higher)
or
Prepend an unicode left-to-right mark to the title/snippet:
.title("\u200e" + titleText)
.snippet("\u200e" + snippetText)

The constructor Marker(MapView) is undefined ?? Why ??

Marker startMarker = new Marker(mapView);
When I type this one to create the Marker is "new Marker(mapView); " red lined.
and i got this message in my headline -->The constructor Marker(MapView) is undefined<--
What is the problem ?
You have to import the OSMBonusPack, because it contains the right definition of Marker.
I had the same issue while following the wiki tutorial.
import org.osmdroid.bonuspack.overlays.Marker
Make sure to download the BonusPack and include the .jar into lib inside your project and link it inside your project properties.
What is the problem ?
It's because the constructor really doesn't exist.
Try this instead :
Marker startMarker = mapView.addMarker(new MarkerOptions().position(markerLatLng)); // markerLatLng is the position for your marker in the map. You can add more options to marker ...

Set a marker icon in Google Maps API

I am using Xamarin and am using the SimpleMapDemo and I have a question about setting a MarkerOptions object to have a different icon.
Here is my current code:
marker1.Icon(SetFeatureDrawable('Icon.png'));
This above code is not working.
May I please have some help to set the icon to be the icon that is in the Drawable folder that has the name of 'Icon.png'?
Thanks in advance
EDIT
Here is my code:
marker1.Icon(BitmapDescriptorFactory.FromResource(Resource.Drawable.monkey));
This is the error I am getting:
Non-invocable member 'Android.Gms.Maps.Model.MarkerOptions.Icon' cannot be used like a method
Here is my code to try and set the icon:
marker1.Icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.monkey);
This is the error I am getting:
CS0200: Property or indexer 'Android.Gms.Maps.Model.MarkerOptions.Icon' cannot be assigned to -- it is read only (CS0200)
Try this code instead:
marker1.InvokeIcon(SetFeatureDrawable('Icon.png'));
In general, Xamarin tries to bind the Java setter/getters to properties. In this case, although MarkerOption.icon looks like a property to C# eyes, it is in fact a Java method. In this case the binding has "translated" the property-like Java method to MarkerOption.InvokeIcon in an attempt to conform with C# design guidelines.
Try in this way:
double latitude = 0.0;
double longitude = 0.0;
MarkerOptions mapMarker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Your title will be here");
mapMarker .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)));
mapView.addMarker(mapMarker );
Try this one, using this i can show custom icon from drawable resource as marker in map
MarkerOptions markerOptions = new MarkerOptions();
// Setting position on the MarkerOptions
markerOptions.SetPosition(lt);
markerOptions.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));

Categories

Resources