带有西里尔文字的Android Google地图标记

时间:2016-02-01 19:00:37

标签: java android google-maps google-maps-markers

我正在尝试在Google地图上设置我的标记片段,但无法在其上显示俄文。

我对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");

绘图路径:

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));
 }

使用代码段添加标记:

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

步骤类:

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();
            }
        }
    }

我得到这些符号:

Screenshot

1 个答案:

答案 0 :(得分:0)

尝试添加从左到右的unicode符号:

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

并检查.java文件编码格式。它可能不是utf-8。