2012-08-14 16 views
13

¿Alguien sabe de una biblioteca para integrar OpenStreetMap en Android? ¿Intento con OSMDROID y MapsForge, más? Es curioso, pero solo encuentro bibliotecas gratuitas.OpenStreetMap en Android

Respuesta

4

Un nuevo sitio ha sido puesto en marcha para ayudar a los desarrolladores que utilizan OpenStreetMap en la Web o en dispositivos móviles: http://switch2osm.org/

3

Las tres bibliotecas más populares para usar OSM en Android son osmdroid, graphhopper y mapsforge.

0

dependencias {

compilación 'org.osmdroid: osmdroid-android: [email protected]'

}

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)); 

        } 

CustomMarkerInfoWindow clase privada extiende InfoWindow { posición int;

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); 
    } 

} 
Cuestiones relacionadas