How to plot a pre-build map from google maps on a MapView

大憨熊 提交于 2019-12-02 06:54:37

问题


I'm trying to read a map from a link (http://maps.google.com/maps/ms?msid=216892338463540803496.000494dd57eb5ebce6db2&msa=0) and plot it on a MapView, is it possible?


回答1:


As you posted more information in my previous answer ("but I don't want to parse the KML and plot point by point. I was wondering if theres a way to plot all at once"), I can now redifine my answer.

You should try these lines and adapt it to your needs:

Intent mapIntent = new Intent(Intent.ACTION_VIEW); 
Uri uri1 = Uri.parse("geo:0,0?q=http://code.google.com/apis/kml/ 
documentation/KML_Samples.kml"); 
mapIntent.setData(uri1); 
startActivity(Intent.createChooser(mapIntent, "Sample")); 

Unfortunately, you won't have any control, as this is not a MapActivity. If you plan to add more stuff on your map, you have to try my first proposal and parse yourself the kml!

Similar question: How to use kml file on mapView in Android




回答2:


You can draw on the Map with Overlays




回答3:


Look at this tutorial: http://codemagician.wordpress.com/2010/05/06/android-google-mapview-tutorial-done-right/

@Override
 public void onCreate(Bundle savedInstanceState)
 {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);

 MapView mapView = (MapView) findViewById(R.id.mapview);
 mapView.setBuiltInZoomControls(true);

 List<Overlay> mapOverlays = mapView.getOverlays();
 Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
 HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this);
 GeoPoint point = new GeoPoint(30443769,-91158458);
 OverlayItem overlayitem = new OverlayItem(point, "Laissez les bon temps rouler!", "I'm in Louisiana!");

 GeoPoint point2 = new GeoPoint(17385812,78480667);
 OverlayItem overlayitem2 = new OverlayItem(point2, "Namashkaar!", "I'm in Hyderabad, India!");

 itemizedoverlay.addOverlay(overlayitem);
 itemizedoverlay.addOverlay(overlayitem2);

 mapOverlays.add(itemizedoverlay);
 }
 @Override
 protected boolean isRouteDisplayed()
 {
 return false;
 }
}


来源:https://stackoverflow.com/questions/7100103/how-to-plot-a-pre-build-map-from-google-maps-on-a-mapview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!