15

有人知道在 Android 中集成 OpenStreetMap 的库吗?我尝试使用 OSMDROID 和 MapsForge,还有吗?这很好奇,但我只找到免费图书馆。

4

5 回答 5

8

有关在 Android 上支持 OpenStreetMap 的软件库列表,请参阅http://wiki.openstreetmap.org/wiki/Android 。免责声明:我是其中之一的作者。

于 2012-11-17T17:51:41.203 回答
5

在 android 中使用 OSM 的三个最流行的库是 osmdroid、graphhopper 和 mapsforge。

于 2013-11-08T05:21:46.457 回答
4

一个新站点已经启动,以帮助开发人员在 Web 或移动设备上使用 OpenStreetMap:http: //switch2osm.org/

于 2012-09-07T08:24:35.227 回答
0

如果你想要一个更接近谷歌地图的 API,你可以试试 AnyMaps: https ://github.com/car2go/AnyMaps

于 2017-04-24T15:09:15.177 回答
0
dependencies {

    compile 'org.osmdroid:osmdroid-android:5.6.5@aar'

}



for (int k = 0; k < mBeanList.size(); k++) {

                        mMyMarkersArray.add(new 

MyMarkers(mBeanList.get(k).getSpecies(),

                                mBeanList.get(k).getArea(), mBeanList.get(k).getTaxon(),
                                Double.parseDouble(mBeanList.get(k).getLatitude()),
                                Double.parseDouble(mBeanList.get(k).getLongitude()),

                                mBeanList.get(k).getDate(), mBeanList.get(k).getTime()));



                        org.osmdroid.views.overlay.Marker osmMarker = new org.osmdroid.views.overlay.Marker(mOpenStreetMapView);
                        Drawable newMarker = ContextCompat.getDrawable(OpenStreetMapActivity.this, R.mipmap.ic_map_72);
                        GeoPoint startPoint = new GeoPoint(Double.parseDouble(mBeanList.get(k).getLatitude()), Double.parseDouble(mBeanList.get(k).getLongitude()));
                        osmMarker.setIcon(newMarker);
                        osmMarker.setPosition(startPoint);
                        osmMarker.setAnchor(org.osmdroid.views.overlay.Marker.ANCHOR_CENTER, org.osmdroid.views.overlay.Marker.ANCHOR_BOTTOM);

                        mOpenStreetMapView.getOverlays().add(osmMarker);
                        mOpenStreetMapView.invalidate();
                        mOpenStreetMapView.setMinZoomLevel(2);
                        IMapController mapController = mOpenStreetMapView.getController();
                        GeoPoint geoIndia = new GeoPoint(20.593684, 78.962880);
                        mapController.setZoom(3);
                        mapController.setCenter(geoIndia);

                        osmMarker.setInfoWindow(new CustomMarkerInfoWindow(mOpenStreetMapView, k));

                    }


private class CustomMarkerInfoWindow extends InfoWindow {
    int position;

    LinearLayout linearLayout;

    //Constructor
    public CustomMarkerInfoWindow(MapView mOpenStreetMapView, int pos) {
        super(R.layout.bonuspack_bubble_black, mOpenStreetMapView);

        linearLayout = (LinearLayout) mView.findViewById(R.id.linear_lay_out_bonuspack_bubble);
        //linearLayout.setVisibility(View.GONE);
        //mOpenStreetMapView.getOverlays().clear();
        this.position = pos;
    }

    @Override
    public void onOpen(Object item) {
        //super.onOpen(item);
        linearLayout.setVisibility(View.VISIBLE);
        TextView species = (TextView) mView.findViewById(R.id.bonuspack_bubble_text_view_species_name);
        species.setText(mBeanList.get(position).getSpecies());
        TextView area = (TextView) mView.findViewById(R.id.bonuspack_bubble_text_view_address);
        area.setText(mBeanList.get(position).getArea());
        TextView taxon = (TextView) mView.findViewById(R.id.bonuspack_bubble_text_view_taxon);
        taxon.setText(mBeanList.get(position).getTaxon());
        TextView dateTime = (TextView) mView.findViewById(R.id.bonuspack_bubble_text_view_date_time);
        dateTime.setText(mBeanList.get(position).getDate());

        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                linearLayout.setVisibility(View.GONE);
            }
        });
    }

    @Override
    public void onClose() {
        //super.onClose();
        //linearLayout.setVisibility(View.GONE);
    }

}
于 2017-09-14T07:23:00.333 回答