use of io.radar.sdk.model.RadarAddress in project capacitor-radar by radarlabs.
the class RadarPlugin method geocode.
@PluginMethod()
public void geocode(final PluginCall call) throws JSONException {
if (!call.hasOption("query")) {
call.reject("query is required");
return;
}
String query = call.getString("query");
Radar.geocode(query, new Radar.RadarGeocodeCallback() {
@Override
public void onComplete(@NotNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
if (status == Radar.RadarStatus.SUCCESS && addresses != null) {
JSObject ret = new JSObject();
ret.put("status", status.toString());
ret.put("addresses", RadarPlugin.jsArrayForJSONArray(RadarAddress.toJson(addresses)));
call.resolve(ret);
} else {
call.reject(status.toString());
}
}
});
}
use of io.radar.sdk.model.RadarAddress in project capacitor-radar by radarlabs.
the class RadarPlugin method autocomplete.
@PluginMethod()
public void autocomplete(final PluginCall call) throws JSONException {
if (!call.hasOption("query")) {
call.reject("query is required");
return;
}
String query = call.getString("query");
if (!call.hasOption("near")) {
call.reject("near is required");
return;
}
JSObject nearObj = call.getObject("near");
double latitude = nearObj.getDouble("latitude");
double longitude = nearObj.getDouble("longitude");
Location near = new Location("RadarSDK");
near.setLatitude(latitude);
near.setLongitude(longitude);
near.setAccuracy(5);
int limit = call.getInt("limit", 10);
Radar.autocomplete(query, near, limit, new Radar.RadarGeocodeCallback() {
@Override
public void onComplete(@NotNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
if (status == Radar.RadarStatus.SUCCESS && addresses != null) {
JSObject ret = new JSObject();
ret.put("status", status.toString());
ret.put("addresses", RadarPlugin.jsArrayForJSONArray(RadarAddress.toJson(addresses)));
call.resolve(ret);
} else {
call.reject(status.toString());
}
}
});
}
use of io.radar.sdk.model.RadarAddress in project flutter-radar by radarlabs.
the class RadarFlutterPlugin method autocomplete.
public void autocomplete(MethodCall call, final Result result) {
String query = call.argument("query");
HashMap nearMap = (HashMap) call.argument("near");
Location near = locationForMap(nearMap);
int limit = call.hasArgument("limit") ? (int) call.argument("limit") : 10;
Radar.autocomplete(query, near, limit, new Radar.RadarGeocodeCallback() {
@Override
public void onComplete(final Radar.RadarStatus status, final RadarAddress[] addresses) {
runOnMainThread(new Runnable() {
@Override
public void run() {
try {
JSONObject obj = new JSONObject();
obj.put("status", status.toString());
if (addresses != null) {
obj.put("addresses", RadarAddress.toJson(addresses));
}
HashMap<String, Object> map = new Gson().fromJson(obj.toString(), HashMap.class);
result.success(map);
} catch (Exception e) {
result.error(e.toString(), e.getMessage(), e.getMessage());
}
}
});
}
});
}
use of io.radar.sdk.model.RadarAddress in project flutter-radar by radarlabs.
the class RadarFlutterPlugin method ipGeocode.
public void ipGeocode(MethodCall call, final Result result) {
Radar.ipGeocode(new Radar.RadarIpGeocodeCallback() {
@Override
public void onComplete(final Radar.RadarStatus status, final RadarAddress address, final boolean proxy) {
runOnMainThread(new Runnable() {
@Override
public void run() {
try {
JSONObject obj = new JSONObject();
obj.put("status", status.toString());
if (address != null) {
obj.put("address", address.toJson());
obj.put("proxy", proxy);
}
HashMap<String, Object> map = new Gson().fromJson(obj.toString(), HashMap.class);
result.success(map);
} catch (Exception e) {
result.error(e.toString(), e.getMessage(), e.getMessage());
}
}
});
}
});
}
use of io.radar.sdk.model.RadarAddress in project flutter-radar by radarlabs.
the class RadarFlutterPlugin method geocode.
public void geocode(MethodCall call, final Result result) {
String query = call.argument("query");
Radar.geocode(query, new Radar.RadarGeocodeCallback() {
@Override
public void onComplete(final Radar.RadarStatus status, final RadarAddress[] addresses) {
runOnMainThread(new Runnable() {
@Override
public void run() {
try {
JSONObject obj = new JSONObject();
obj.put("status", status.toString());
if (addresses != null) {
obj.put("addresses", RadarAddress.toJson(addresses));
}
HashMap<String, Object> map = new Gson().fromJson(obj.toString(), HashMap.class);
result.success(map);
} catch (Exception e) {
result.error(e.toString(), e.getMessage(), e.getMessage());
}
}
});
}
});
}
Aggregations