2014-06-15 67 views
1

我想在我的地圖添加地圖標記如何在地圖上添加地圖標記爲OpenMapQuest

My code is as below

FrgBufLocation.java

public class FrgBufLocation extends Fragment{ 

    double dummyLatitude=12.931841; 
    double dummyLongitude=77.622236; 

    //Constructor declaration on type newInstance 
    public static FrgBufLocation newInstance(String _buf_off_id) { 
     FrgBufLocation fragment = new FrgBufLocation(); 

     buf_off_id=_buf_off_id; 

     return fragment; 
    } 


    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     View rootView = inflater.inflate(R.layout.frg_buf_location, container,false); 
     setHasOptionsMenu(true);///For using actionbar menu from fragment 

     MapView map = (MapView) rootView.findViewById(R.id.map); 
      map.getController().setZoom(9); 
      map.getController().setCenter(new GeoPoint(dummyLatitude,dummyLongitude)); 
      map.setBuiltInZoomControls(true); 

     return rootView; 
    } 
} 

我得到輸出 ::

enter image description here

如何獲得這樣一個輸出::(We can notice the below image has pinpoint pointed

enter image description here

回答

0

您可以繪製標記類似:

... ... 
    List<Overlay> mapOverlays = mapView.getOverlays(); 
    Drawable drawable = this.getResources().getDrawable(R.drawable.marker); 

    //myItemlizedOverLay is your customised ItemizedOverlay 
    myItemlizedOverLay itemizedoverlay = new myItemlizedOverLay(drawable, this); 

    GeoPoint point = new GeoPoint(dummyLatitude,dummyLongitude);    
    OverlayItem overlayitem = new OverlayItem(point, "address_name", "address"); 

    itemizedoverlay.addOverlay(overlayitem); 
    mapOverlays.add(itemizedoverlay); 
    map.getController().animateTo(point); 
    ... ... 

希望這有助於。

0

使用POI,下面的代碼是從JavaScript API那麼一點點不同的語法。

var POITruck1038=new MQA.Poi({lat:truckLatitude, lng:truckLongitude}); 
    map.addShape(POITruck1038); 
+0

JS API與Android的非常不同,所以這個答案沒有用。 – WWJD

相關問題