I use Google Maps Android API v2 with Android to show current position with nearby markers. Nearby places locations and titles are received using Google Places API.
The problem is that non-english names at title/snippet are shown in fail way. For the instance, Hebrew names.
The sreenshot is attached.
)
Call the changeMarkerPosition() function and pass the marker object in it. The setPosition() will change the marker position on google map based on the specified latitude and longitude.
For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements.
Since Arabic and Hebrew are causing problems, and English and Russian are not, I am going to guess that something is broken in the default info window implementation with respect to right-to-left (RTL) languages. Particularly if you are running your tests on Android 4.2, it may be that Maps V2's default info window contents have incorrectly applied the various RTL-related attributes.
Fortunately, you can supply your own info window contents, by implementing InfoWindowAdapter
and having getInfoContents()
return the View
that you want to use in the info window.
For example, this sample project (from tomorrow's update to my book) shows customizing the info window using this InfoWindowAdapter
:
class PopupAdapter implements InfoWindowAdapter {
LayoutInflater inflater=null;
PopupAdapter(LayoutInflater inflater) {
this.inflater=inflater;
}
@Override
public View getInfoWindow(Marker marker) {
return(null);
}
@Override
public View getInfoContents(Marker marker) {
View popup=inflater.inflate(R.layout.popup, null);
TextView tv=(TextView)popup.findViewById(R.id.title);
tv.setText(marker.getTitle());
tv=(TextView)popup.findViewById(R.id.snippet);
tv.setText(marker.getSnippet());
return(popup);
}
}
If you want to replace the whole window, you would have getInfoWindow()
return a View
. If getInfoWindow()
returns null
, getInfoContents()
is used for the contents of the window. You then attach an instance of InfoWindowAdapter
via setInfoWindowAdapter()
on your GoogleMap
.
In your case, you could use your own layout to make sure that you are implementing RTL correctly. That should, in principle, clear up this problem. It is conceivable that Maps V2 does something strange that breaks RTL code that normally should work, in which case you'd need to file an issue.
Adding more info regarding CommnsWare answer:
As of the moment I am writing this commend, it seems that the map itself is layout_direction="LTR"
which means that your titles will not be flipped on RTL desktops. The solution is simple:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layoutDirection="locale"
>
....
</RelativeLayout>
Note that I am using the locale's layout direction and not the inherited direction. I commented this on the corresponding Google bug report here: https://code.google.com/p/gmaps-api-issues/issues/detail?id=5608#makechanges
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With