0

I am trying to set up snippets of my markers on Google Map, but can't get russian text on it.

My query to Google Map API:

urlString.append("http://maps.googleapis.com/maps/api/directions/json");


urlString.append("?origin=");// from
urlString.append(Double.toString(sourcelat));
urlString.append(",");
urlString.append(Double.toString(sourcelog));
urlString.append("&destination=");// to
urlString.append(Double.toString(destlat));
urlString.append(",");
urlString.append(Double.toString(destlog));
urlString.append("&sensor=false&mode=" + mode + "&alternatives=true&language=" + "ru");

Drawing path:

for (int z = 0; z < list.size() - 1; z++) {
        LatLng src = list.get(z);
        LatLng dest = list.get(z + 1);
        Polyline line = mMap.addPolyline(new PolylineOptions()
                .add(new LatLng(src.latitude, src.longitude), new LatLng(dest.latitude, dest.longitude))
                .width(5) //Default = 4
                .color(ContextCompat.getColor(context, R.color.colorAppPrimary))
                .geodesic(true));
 }

Adding markers with snippets:

mMap.addMarker(new MarkerOptions()
                    .position(step.location)
                    .title(step.distance)
                    .snippet(step.instructions)
                    .icon(BitmapDescriptorFactory.fromResource(iconId)));

Step class:

private class Step {
        public String distance;
        public LatLng location;
        public String instructions;

        Step(JSONObject stepJSON) {
            JSONObject startLocation;
            try {
                distance = stepJSON.getJSONObject("distance").getString("text");
                startLocation = stepJSON.getJSONObject("start_location");
                location = new LatLng(startLocation.getDouble("lat"), startLocation.getDouble("lng"));
                try {
                    instructions = URLDecoder.decode(Html.fromHtml(stepJSON.getString("html_instructions")).toString(), "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

And I get these symbols:

Screenshot

Roman Svyatnenko
  • 699
  • 12
  • 27
  • possible duplicate of http://stackoverflow.com/questions/5396560/how-do-i-convert-special-utf-8-chars-to-their-iso-8859-1-equivalent-using-javasc – abielita Feb 03 '16 at 04:13

1 Answers1

0

try to add left-to-right unicode symbol:

.title("\u200e" + "абвгд");

and check .java file encoding format. It may be not utf-8.

Vyacheslav
  • 26,359
  • 19
  • 112
  • 194