Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/woheller69/photondialog
Android DialogFragment for search via Photon API
https://github.com/woheller69/photondialog
android-library elasticsearch geocoding java openstreetmap photon
Last synced: about 1 month ago
JSON representation
Android DialogFragment for search via Photon API
- Host: GitHub
- URL: https://github.com/woheller69/photondialog
- Owner: woheller69
- License: gpl-3.0
- Created: 2022-11-02T12:57:46.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-12T08:56:51.000Z (about 1 year ago)
- Last Synced: 2023-10-13T02:50:24.182Z (about 1 year ago)
- Topics: android-library, elasticsearch, geocoding, java, openstreetmap, photon
- Language: Java
- Homepage:
- Size: 290 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PhotonDialog
### Overview
This library contains an Android DialogFragment for search-as-you-type via the photon geocoding API.
(see https://github.com/komoot/photon and https://photon.komoot.io/)
You can type an address and get the coordinates back. The result will be shown on a map.
### Installation
Add the JitPack repository to your root build.gradle at the end of repositories:
```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```Add the library dependency to your build.gradle file.
```gradle
dependencies {
implementation 'com.github.woheller69:PhotonDialog:V1.5'
}
```### Usage
Let your activity implement PhotonDialog.PhotonDialogResult
```
public class MainActivity extends AppCompatActivity implements PhotonDialog.PhotonDialogResult```
and override onPhotonDialogResult, where you define what to do with the result
```
@Override
public void onPhotonDialogResult(City city) {String cityName = city.getCityName();
String countryCode = city.getCountryCode();
float lon = city.getLongitude();
float lat = city.getLatitude();
// do what you need to do
}
```Open a search dialog:
```
FragmentManager fragmentManager = getSupportFragmentManager();
PhotonDialog photonDialog = new PhotonDialog();
photonDialog.setTitle("Search");
photonDialog.setNegativeButtonText("Cancel");
photonDialog.setPositiveButtonText("Select");
//Optional: Define countries. Otherwise locations in all countries are shown
ArrayList countryList = new ArrayList<>();
countryList.add("DE");
countryList.add("AT");
photonDialog.setCountryList(countryList);
//Optional: Define User-Agent
photonDialog.setUserAgentString(BuildConfig.APPLICATION_ID+"/"+BuildConfig.VERSION_NAME);
photonDialog.show(fragmentManager, "");
getSupportFragmentManager().executePendingTransactions();
photonDialog.getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);```
### License
This library is licensed under the GPLv3.
The library uses:
- Leaflet which is licensed under the very permissive 2-clause BSD License
- Map data from OpenStreetMap, licensed under the Open Data Commons Open Database License (ODbL) by the OpenStreetMap Foundation (OSMF) (https://www.openstreetmap.org/copyright)
- Search-as-you-type location search is provided by [photon API](https://photon.komoot.io), based on OpenStreetMap. See also (https://github.com/komoot/photon)
- Android Volley (com.android.volley) (https://github.com/google/volley) which is licensed under Apache License Version 2.0
- AndroidX libraries (https://github.com/androidx/androidx) which is licensed under Apache License Version 2.0
- AutoSuggestTextViewAPICall (https://github.com/Truiton/AutoSuggestTextViewAPICall) which is licensed under Apache License Version 2.0