Search code examples
javaandroidmapsopenstreetmaposmdroid

How to implement open street map on android with infowindow on markers?


How to implement open street map on android with infowindow on markers?

OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);
        openStreetMap = (MapView)findViewById(R.id.openmapview);
        openStreetMap.setBuiltInZoomControls(true);
        openStreetMapController = openStreetMap.getController();
        openStreetMapController.setZoom(16);
        openStreetMap.setMultiTouchControls(true);

    GeoPoint initialLocation = new GeoPoint(lat , lng);
    centerMap(initialLocation);
    addLocation(lat ,lng , R.drawable.marker);}

This is my code and y want to add markers with it's infoWindows like googleMaps


Solution

  • A sample using marker was recently added. The original source is from osmbonuspack's tutorial

    The sample is located here

    The basic code is this

    GeoPoint startPoint = new GeoPoint(38.8977, -77.0365); //white house Marker startMarker = new Marker(mMapView); startMarker.setPosition(startPoint); startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); startMarker.setIcon(getResources().getDrawable(R.drawable.icon)); startMarker.setTitle("White House"); startMarker.setSnippet("The White House is the official residence and principal workplace of the President of the United States."); startMarker.setSubDescription("1600 Pennsylvania Ave NW, Washington, DC 20500"); mMapView.getOverlays().add(startMarker); mMapView.invalidate();