2014-06-28 35 views
0

我在做什么 ::变焦不能在地图里面工作在滚动视图的Android

  • 我使用贴图
  • 我的巡航能力滚动视图内mapwidget Mapquest服务插件和API
  • 我可以点击地图中的地图标记也

发生了什么 ::

  • 我不能缩小地图,
  • 我可以看到变焦按钮clickit还,但它不会放大

代码 ::

MyFragment.java

public class MyFragment extends Fragment{ 

    protected MapView map; 
    AnnotationView annotation; 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     View rootView = inflater.inflate(R.layout.fragment, container,false); 
     map = (MapView) rootView.findViewById(R.id.map); 
     map.getController().setZoom(10); 
     map.getController().setCenter(new GeoPoint(12.918609,77.668912)); 
     map.setBuiltInZoomControls(true); 

     // initialize the annotation to be shown later 
     annotation = new AnnotationView(map); 

     //addPolyOverlay(); 
     // addLineOverlay(); 

     return rootView; 
    } 

    @Override 
    public void onStart() { 
     // TODO Auto-generated method stub 
     super.onStart(); 


     addPoiOverlay(); 
    } 


    // add an itemized overlay to map 
    private void addPoiOverlay() { 

     // use a custom POI marker by referencing the bitmap file directly, 
     // using the filename as the resource ID 
     Drawable icon = getResources().getDrawable(R.drawable.distance_icon_large); 
     final DefaultItemizedOverlay poiOverlay = new DefaultItemizedOverlay(icon); 

     // set GeoPoints and title/snippet to be used in the annotation view 
     OverlayItem poi1 = new OverlayItem(new GeoPoint (12.918609,77.668912), "Denver, Colorado", "MapQuest Headquarters"); 
     poiOverlay.addItem(poi1); 
     OverlayItem poi2 = new OverlayItem(new GeoPoint (12.956868,77.701148), "Palo Alto, California", "AOL Offices"); 
     poiOverlay.addItem(poi2); 

     // add a tap listener for the POI overlay 
     poiOverlay.setTapListener(new ItemizedOverlay.OverlayTapListener() { 
      @Override 
      public void onTap(GeoPoint pt, MapView mapView) { 
       // when tapped, show the annotation for the overlayItem 
       int lastTouchedIndex = poiOverlay.getLastFocusedIndex(); 
       if(lastTouchedIndex>-1){ 
        OverlayItem tapped = poiOverlay.getItem(lastTouchedIndex); 
        annotation.showAnnotationView(tapped); 
       } 
      } 
     }); 



     map.getOverlays().add(poiOverlay); 
    } 

} 

fragment.xml之

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" > 

      <com.mapquest.android.maps.MapView 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/map" 
       android:layout_width="match_parent" 
       android:layout_height="700dp" 
       android:apiKey="My-Key" 
       android:focusableInTouchMode="true" 
       android:clickable="true" 
       android:padding="5dp" /> 
     </LinearLayout> 
    </ScrollView> 

</LinearLayout> 

回答

0

您可能需要在适当覆盖在滚动视图的touchlistener并转发这些事件的MapView。问题是滚动视图正在接管触摸监听器而没有正确转发出去。

在一个滚动视图内的mapview似乎凌乱,但....

相关问题