通過jsonparsing我再次解析所有的字符串值,我需要顯示的MapView緯度和經度..,我需要所有的座標存儲在一個單獨的數組 請人幫助我..提前 感謝從json解析獲取座標並在mapview中顯示?
1
A
回答
1
我不確定你的parseString函數怎麼樣,我假設你可以得到2個字符串的lat和long值。作爲跟隨
String coordinates[] = {"...","..."};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);
p = new GeoPoint(
(int) (lat * 1E6),
(int) (lon * 1E6));
//mc is MapView object
mc.animateTo(p);
mc.setZoom(15);
mapView.invalidate();
要在地圖上顯示的剩餘部分都可以做,你需要創建在res位圖精確的疊加/文件夾
MarkerOverlay mark = new MarkerOverlay();
listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mark);
mapView.invalidate();
類MapOverlay的可以被定義因此:
class MarkerOverlay extends com.google.android.maps.Overlay
{
//create a constructor here with p.x and p.y as parameters
@Override
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);
Point screenPts = new Point();
Bitmap bmp = BitmapFactory.decodeResource(
getResources(), R.drawable.pushpin);
GeoPoint point = new GeoPoint(
(int) (p.x * 1E6),
(int) (p.y * 1E6));
mapView.getProjection().toPixels(point, screenPts);
canvas.drawBitmap(bmp, screenPts.x-16, screenPts.y-32, null);
canvas.drawText(parts[0],screenPts.x-16 , screenPts.y-40, new Paint());
}
}
}
return true;
}
}
+0
不需要這個** GeoPoint point = new GeoPoint((int)(px * 1E6),(int)(py * 1E6)); **您可以在mapView.getProjection()中直接使用GeoPoint的p對象).toPixels(p,screenPts); ** – Pratik
相關問題
- 1. 解析json中的座標以在地圖上顯示?
- 2. 獲取和解析JSON與從gmaps的jquery找到座標
- 3. 如何從URL獲取並解析Json?
- 4. 解析iOS中的JSON數據(Objective-c)並在TableView中顯示。獲取空值
- 5. 從URL獲取JSON文件並顯示
- 6. Reactjs從(地理)json獲取座標
- 7. 如何顯示圖片並獲取鼠標點擊座標
- 8. 在Android中獲取地圖的中心座標Mapview
- 9. 解析json並用tableview顯示
- 10. 解析並顯示從json中提取的信息從google map api返回
- 11. 在MapVIew中獲取錯誤 - 無效的座標 - 初學者
- 12. 從openlayers中獲取座標
- 13. 獲取JSON數據並顯示在DIV
- 14. 在地圖上顯示之前從API請求獲取座標
- 15. 在Rails中解析JSON和顯示值
- 16. 在UITableView中顯示解析的JSON
- 17. 從候選回答中解析ESRI JSON座標文字
- 18. JSON解析值不顯示
- 19. 在Actionscript中獲取和解析JSON
- 20. 在Json解析中獲取模型
- 21. 在iOS中獲取和解析JSON
- 22. 在Android中解析JSON,未獲取值
- 23. 在Python中解析JSON時獲取Keyerror
- 24. json從url解析數據獲取nullpointException
- 25. 如何解析JSON並使用目標C獲取特定值?
- 26. 解析json並在popop中顯示圖像
- 27. 如何解析json數據並使用aysnctask在listview中顯示
- 28. 如何解析JSON對象並在表中顯示?
- 29. 如何解析JSON數組並在ListView中顯示它?
- 30. XML文件解析並獲取標籤?
問題出在哪裏?如果你獲得了字符串值,那麼接下來呢? – Pratik