[英]Android Google Map marker with cyrillic text
I am trying to set up snippets of my markers on Google Map, but can't get russian text on it. 我正在尝试在Google Map上设置标记片段,但无法在上面获得俄语文字。
My query to Google Map API: 我对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: 我得到这些符号:
try to add left-to-right unicode symbol: 尝试添加从左到右的unicode符号:
.title("\u200e" + "абвгд");
and check .java file encoding format. 并检查.java文件编码格式。 It may be not utf-8. 它可能不是utf-8。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.