如何使用 OSMDROID/OSMBonusPack 更改标记气泡

How to change the marker bubble using OSMDROID/OSMBonusPack

te我正在尝试用 OSM 地图替换我应用程序中的 google 地图。我一直在尝试按照他们如何使用 Jitpack 安装和导入项目来使用 this。 它工作正常。点击标记默认信息气泡(一些浅灰色的)显示。如果我想修改标记气泡的背景,我该怎么办?我的代码中没有使用任何类型的 onClick 方法

 import android.app.Fragment;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.osmdroid.api.IMapController;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.Marker;
import org.osmdroid.views.overlay.ScaleBarOverlay;
import java.util.ArrayList;
import java.util.List;
import demo.exe.exe.R;
import demo.exe.exe.model.Education.EducationServiceProviderItem;
import demo.exe.exe.utils.AppConstants;


public class MapFragmentOSM extends Fragment implements View.OnClickListener {

    private ArrayList<EducationServiceProviderItem> educationServiceProvider=null;
MapView mapView;
    int subcategotyId;
    View rootView;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        double latDouble,longDouble;
        int i=0;
        super.onCreate(savedInstanceState);
        rootView = inflater.inflate(R.layout.fragment_map, container,
                false);

        mapView = (MapView) rootView.findViewById(R.id.mapview);
        mapView.setClickable(true);
        mapView.setBuiltInZoomControls(true);
        mapView.setMultiTouchControls(true);
        mapView.setUseDataConnection(true);

;
        mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);

        IMapController mapViewController = mapView.getController();



        if(locationNameId==1) {

            mapViewController.setZoom(18);
            mapViewController.setCenter(AppConstants.BAUNIA1);
        }
        else if(locationNameId==2)
        {
            mapViewController.setZoom(17);
            mapViewController.setCenter(AppConstants.PARIS1);
        }
        switch (categoryId)
        {
            case AppConstants.EDUCATION:
                if(educationServiceProvider!=null) {
                    for (EducationServiceProviderItem et : educationServiceProvider) {
                    //    LatLng location = new LatLng(Double.parseDouble(et.getLatitude()), Double.parseDouble(et.getLongitude()));
                        subcategotyId = et.getEduSubCategoryId();
                        latDouble=Double.parseDouble(et.getLatitude());
                        longDouble=Double.parseDouble(et.getLongitude());
                      GeoPoint point=  new GeoPoint(latDouble,longDouble);
                        drawMarkerEdu(point, et.getEduNameEng(),et.getAddress(), et.getEduSubCategoryId());
                    }
                }
                break;


            default:
                break;

        }

        //Add Scale Bar
        ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(mapView);
        mapView.getOverlays().add(myScaleBarOverlay);


        return rootView;
    }
    private void drawMarkerEdu(GeoPoint point,String title,String address,int subcategotyId) {
        Marker marker = new Marker(mapView);
        marker.setPosition(point);
        marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);


        if (subcategotyId >= 1 && subcategotyId <= 12)
            marker.setIcon(this.getResources().getDrawable(R.drawable.pin_feroza));
        else if (subcategotyId >= 13 && subcategotyId <= 17)
            marker.setIcon(this.getResources().getDrawable(R.drawable.pin_blue));
        else if (subcategotyId >= 18 && subcategotyId <= 19)
            marker.setIcon(this.getResources().getDrawable(R.drawable.pin_pink));
        else if (subcategotyId >= 20 && subcategotyId <= 21)
            marker.setIcon(this.getResources().getDrawable(R.drawable.pin_green));
        else if (subcategotyId >= 22 && subcategotyId <= 26)
            marker.setIcon(this.getResources().getDrawable(R.drawable.pin_yellow));
        marker.setSnippet(title);
        marker.setSubDescription(address);
        mapView.getOverlays().add(marker);


    }
    @Override
    public void onClick(View v) {

    }
}

任何建议将不胜感激!

This tutorial正是您想要的。基本上你覆盖了 InfoWindow class 并给它你自己的布局。