0
NominatimPOIProvider poiProvider = new NominatimPOIProvider();
    ArrayList<POI> pois = poiProvider.getPOICloseTo(startPoint, "cinema", 50, 0.1);
    FolderOverlay poiMarkers = new FolderOverlay(this);
    map.getOverlays().add(poiMarkers);
    Drawable poiIcon = getResources().getDrawable(R.drawable.marker_poi_default);
    for (POI poi:pois){
        Marker poiMarker = new Marker(map);
        poiMarker.setTitle(poi.mType);
        poiMarker.setSnippet(poi.mDescription);
        poiMarker.setPosition(poi.mLocation);
        poiMarker.setIcon(poiIcon);
        if (poi.mThumbnail != null){
            poiMarker.setImage(new BitmapDrawable(poi.mThumbnail));
        }
        poiMarkers.add(poiMarker);
    }

I'm getting this error: NominatimPOIProvider (String) in NominatimPOIProvider cannot be applied to ()

I found this answer but it's not solving my problem: OpenStreetMap POIs with Nominatim - error

1 Answers1

1

It seems the tutorial is outdated because there is no longer a constructor without parameter for NominatimPOIProvider. You are required to specify user agent which will be used in headers sent to a Nominatim service provider. More details can be found in this issue and in usage policy of openstreetmap.

Use something like:

NominatimPOIProvider poiProvider = new NominatimPOIProvider("YourUserAgentSpecificForYourApplicationOrWhatever");
Josef Adamcik
  • 5,620
  • 3
  • 36
  • 42
  • So from reading the links you posted, it sounds like I put my apps package name there, right? – james burnison Sep 29 '17 at 13:02
  • I did that and it solved that problem. Now I'm getting this when truing to run the app. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.JEB.trailmaps/com.JEB.trailmaps.MainActivity}: android.os.NetworkOnMainThreadException – james burnison Sep 29 '17 at 13:03
  • @jamesburnison You cannot do a network requests on main thread on android. NominatimPOIProvider is calling some API so you cannot call getPOICloseTo on the main thread. This is not related to osmdroid at all, it's just one of the andriod development basics. See related SO question: https://stackoverflow.com/questions/6343166/how-do-i-fix-android-os-networkonmainthreadexception – Josef Adamcik Sep 29 '17 at 13:12
  • Crap. Unfortunately I have a very poor understanding of how to use async task. I don't do this stuff everyday. Something I found I enjoy doing in my spare time. The very few times I have used it I struggled with it and still do. – james burnison Sep 29 '17 at 15:55
  • 1
    I just fixed the tuto for user-agent change. @james Follow the tuto from the beginning (tutorial_0), it explains how to proceed. – MKer Sep 29 '17 at 20:24
  • Awesome. Thanks. It works with that strictmode but from looking online I understand I shouldn't use that. I was at least able to use it to confirm @Josef answer does answer my question. Thanks again. You both were very helpfull. – james burnison Sep 29 '17 at 21:04