| | |
| | | import cn.sinata.xldutils.utils.SPUtils |
| | | import com.google.android.gms.common.api.ApiException |
| | | import com.google.android.gms.common.util.CollectionUtils.listOf |
| | | import com.google.android.gms.maps.* |
| | | import com.google.android.gms.maps.model.* |
| | | import com.google.android.gms.maps.CameraUpdateFactory |
| | | import com.google.android.gms.maps.GoogleMap |
| | | import com.google.android.gms.maps.GoogleMapOptions |
| | | import com.google.android.gms.maps.SupportMapFragment |
| | | import com.google.android.gms.maps.model.BitmapDescriptor |
| | | import com.google.android.gms.maps.model.BitmapDescriptorFactory |
| | | import com.google.android.gms.maps.model.CameraPosition |
| | | import com.google.android.gms.maps.model.Circle |
| | | import com.google.android.gms.maps.model.CircleOptions |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import com.google.android.gms.maps.model.LatLngBounds |
| | | import com.google.android.gms.maps.model.Marker |
| | | import com.google.android.gms.maps.model.MarkerOptions |
| | | import com.google.android.gms.maps.model.Polygon |
| | | import com.google.android.gms.maps.model.PolygonOptions |
| | | import com.google.android.gms.maps.model.Polyline |
| | | import com.google.android.gms.maps.model.PolylineOptions |
| | | import com.google.android.libraries.mapsplatform.transportation.consumer.view.ConsumerGoogleMap |
| | | import com.google.android.libraries.places.api.Places |
| | | import com.google.android.libraries.places.api.model.* |
| | | import com.google.android.libraries.places.api.model.AutocompletePrediction |
| | | import com.google.android.libraries.places.api.model.AutocompleteSessionToken |
| | | import com.google.android.libraries.places.api.model.Place |
| | | import com.google.android.libraries.places.api.model.PlaceLikelihood |
| | | import com.google.android.libraries.places.api.model.TypeFilter |
| | | import com.google.android.libraries.places.api.net.FetchPlaceRequest |
| | | import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest |
| | | import com.google.android.libraries.places.api.net.FindCurrentPlaceRequest |
| | |
| | | import com.igo.user.IGoApplication |
| | | import com.igo.user.R |
| | | import com.igo.user.utils.Const |
| | | import okhttp3.* |
| | | import java.util.* |
| | | import okhttp3.MediaType |
| | | import okhttp3.OkHttpClient |
| | | import okhttp3.Request |
| | | import okhttp3.RequestBody |
| | | import okhttp3.Response |
| | | import java.util.Arrays |
| | | import java.util.Collections.emptyList |
| | | import kotlin.collections.get |
| | | |
| | | |
| | | object AMapKit { |
| | |
| | | ) { |
| | | //https://maps.googleapis.com/maps/api/directions/json?origin=39.99709957757345,116.31184045225382&destination=39.949158391497214,116.4154639095068&sensor=false&mode=driving |
| | | var language = SPUtils.instance().getString("language") |
| | | if (language.isEmpty()) { |
| | | language = "en" |
| | | } |
| | | var centerStr = getPointStr(centerPoint ?: arrayListOf()) |
| | | var url = "https://maps.googleapis.com/maps/api/directions/json" + |
| | | "?origin=" + start.latitude.toString() + "," + start.longitude.toString() + |
| | |
| | | ) { |
| | | //https://maps.googleapis.com/maps/api/directions/json?origin=39.99709957757345,116.31184045225382&destination=39.949158391497214,116.4154639095068&sensor=false&mode=driving |
| | | var language = SPUtils.instance().getString("language") |
| | | if (language.isEmpty()){ |
| | | language = "en" |
| | | } |
| | | val client: OkHttpClient = OkHttpClient().newBuilder() |
| | | .build() |
| | | val mediaType: MediaType = MediaType.parse("text/plain")!! |
| | |
| | | function: ( List<GoogleNearBean2.ResultsBean>) -> Unit |
| | | ) { |
| | | var language = SPUtils.instance().getString("language") |
| | | if (language.isEmpty()){ |
| | | language = "en" |
| | | } |
| | | var url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json" + |
| | | "?location="+ lat.toString()+","+lng.toString() + |
| | | "&radius=1500" + |
| | |
| | | fun searchSite(context: Context, content: String?, cityName: String, function: (List<AutocompletePrediction>) -> Unit) { |
| | | val placesClient = Places.createClient(context) |
| | | var language = SPUtils.instance().getString("language") |
| | | if (language.isEmpty()){ |
| | | language = "en" |
| | | } |
| | | val token = AutocompleteSessionToken.newInstance() |
| | | // val bounds = RectangularBounds.newInstance( |
| | | // LatLng(-33.880490, 151.184363), LatLng(-33.858754, 151.229596)) |
| | |
| | | */ |
| | | fun getAddress(context: Context,lat:Double,lon:Double,function:(String)->Unit) { |
| | | var language = SPUtils.instance().getString("language") |
| | | if (language.isEmpty()){ |
| | | language = "en" |
| | | } |
| | | var url = "https://maps.googleapis.com/maps/api/geocode/json" + |
| | | "?latlng="+ lat.toString() +","+lon.toString() + |
| | | "&language="+language+ |
| | |
| | | } |
| | | fun getAddressName(context: Context,lat:Double,lon:Double,function:(String)->Unit) { |
| | | var language = SPUtils.instance().getString("language") |
| | | if (language.isEmpty()){ |
| | | language = "en" |
| | | } |
| | | var url = "https://maps.googleapis.com/maps/api/geocode/json" + |
| | | "?latlng="+ lat.toString() +","+lon.toString() + |
| | | "&language="+language+ |