use of com.yandex.mapkit.geometry.Point in project react-native-yamap by volga-volga.
the class YamapMarker method animatedMoveTo.
public void animatedMoveTo(Point point, final float duration) {
PlacemarkMapObject placemark = (PlacemarkMapObject) this.getMapObject();
Point p = placemark.getGeometry();
final double startLat = p.getLatitude();
final double startLon = p.getLongitude();
final double deltaLat = point.getLatitude() - startLat;
final double deltaLon = point.getLongitude() - startLon;
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
valueAnimator.setDuration((long) duration);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
try {
float v = animation.getAnimatedFraction();
moveAnimationLoop(startLat + v * deltaLat, startLon + v * deltaLon);
} catch (Exception ex) {
// I don't care atm..
}
}
});
valueAnimator.start();
}
use of com.yandex.mapkit.geometry.Point in project react-native-yamap by volga-volga.
the class YamapMarker method moveAnimationLoop.
public void moveAnimationLoop(double lat, double lon) {
PlacemarkMapObject placemark = (PlacemarkMapObject) this.getMapObject();
placemark.setGeometry(new Point(lat, lon));
}
use of com.yandex.mapkit.geometry.Point in project react-native-yamap by volga-volga.
the class YamapView method convertRouteSection.
private WritableMap convertRouteSection(Route route, final Section section, Polyline geometry, Weight routeWeight, int routeIndex) {
SectionMetadata.SectionData data = section.getMetadata().getData();
WritableMap routeMetadata = Arguments.createMap();
WritableMap routeWeightData = Arguments.createMap();
WritableMap sectionWeightData = Arguments.createMap();
Map<String, ArrayList<String>> transports = new HashMap<>();
routeWeightData.putString("time", routeWeight.getTime().getText());
routeWeightData.putInt("transferCount", routeWeight.getTransfersCount());
routeWeightData.putDouble("walkingDistance", routeWeight.getWalkingDistance().getValue());
sectionWeightData.putString("time", section.getMetadata().getWeight().getTime().getText());
sectionWeightData.putInt("transferCount", section.getMetadata().getWeight().getTransfersCount());
sectionWeightData.putDouble("walkingDistance", section.getMetadata().getWeight().getWalkingDistance().getValue());
routeMetadata.putMap("sectionInfo", sectionWeightData);
routeMetadata.putMap("routeInfo", routeWeightData);
routeMetadata.putInt("routeIndex", routeIndex);
final WritableArray stops = new WritableNativeArray();
for (RouteStop stop : section.getStops()) {
stops.pushString(stop.getStop().getName());
}
routeMetadata.putArray("stops", stops);
if (data.getTransports() != null) {
for (Transport transport : data.getTransports()) {
for (String type : transport.getLine().getVehicleTypes()) {
if (type.equals("suburban"))
continue;
if (transports.get(type) != null) {
ArrayList<String> list = transports.get(type);
if (list != null) {
list.add(transport.getLine().getName());
transports.put(type, list);
}
} else {
ArrayList<String> list = new ArrayList<>();
list.add(transport.getLine().getName());
transports.put(type, list);
}
routeMetadata.putString("type", type);
int color = Color.BLACK;
if (transportHasStyle(transport)) {
try {
color = transport.getLine().getStyle().getColor();
} catch (Exception ignored) {
}
}
routeMetadata.putString("sectionColor", formatColor(color));
}
}
} else {
routeMetadata.putString("sectionColor", formatColor(Color.DKGRAY));
if (section.getMetadata().getWeight().getWalkingDistance().getValue() == 0) {
routeMetadata.putString("type", "waiting");
} else {
routeMetadata.putString("type", "walk");
}
}
WritableMap wTransports = Arguments.createMap();
for (Map.Entry<String, ArrayList<String>> entry : transports.entrySet()) {
wTransports.putArray(entry.getKey(), Arguments.fromList(entry.getValue()));
}
routeMetadata.putMap("transports", wTransports);
Polyline subpolyline = SubpolylineHelper.subpolyline(route.getGeometry(), section.getGeometry());
List<Point> linePoints = subpolyline.getPoints();
WritableArray jsonPoints = Arguments.createArray();
for (Point point : linePoints) {
WritableMap jsonPoint = Arguments.createMap();
jsonPoint.putDouble("lat", point.getLatitude());
jsonPoint.putDouble("lon", point.getLongitude());
jsonPoints.pushMap(jsonPoint);
}
routeMetadata.putArray("points", jsonPoints);
return routeMetadata;
}
use of com.yandex.mapkit.geometry.Point in project react-native-yamap by volga-volga.
the class YamapPolygonManager method setInnerRings.
@ReactProp(name = "innerRings")
public void setInnerRings(View view, ReadableArray _rings) {
ArrayList<ArrayList<Point>> rings = new ArrayList<>();
if (_rings != null) {
for (int j = 0; j < _rings.size(); ++j) {
ReadableArray points = _rings.getArray(j);
if (points != null) {
ArrayList<Point> parsed = new ArrayList<>();
for (int i = 0; i < points.size(); ++i) {
ReadableMap markerMap = points.getMap(i);
if (markerMap != null) {
double lon = markerMap.getDouble("lon");
double lat = markerMap.getDouble("lat");
Point point = new Point(lat, lon);
parsed.add(point);
}
}
rings.add(parsed);
}
}
}
castToPolygonView(view).setInnerRings(rings);
}
use of com.yandex.mapkit.geometry.Point in project react-native-yamap by volga-volga.
the class YamapPolygonManager method setPoints.
// props
@ReactProp(name = "points")
public void setPoints(View view, ReadableArray points) {
if (points != null) {
ArrayList<Point> parsed = new ArrayList<>();
for (int i = 0; i < points.size(); ++i) {
ReadableMap markerMap = points.getMap(i);
if (markerMap != null) {
double lon = markerMap.getDouble("lon");
double lat = markerMap.getDouble("lat");
Point point = new Point(lat, lon);
parsed.add(point);
}
}
castToPolygonView(view).setPolygonPoints(parsed);
}
}
Aggregations