Skip to content

Commit

Permalink
Use composite icon for user pin
Browse files Browse the repository at this point in the history
  • Loading branch information
vbazhenov committed Oct 29, 2018
1 parent 0b1a4f3 commit f294fb9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/main/java/com/yandex/mapkitdemo/UserLocationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import com.yandex.mapkit.geometry.Point;
import com.yandex.mapkit.layers.ObjectEvent;
import com.yandex.mapkit.map.CameraPosition;
import com.yandex.mapkit.map.CompositeIcon;
import com.yandex.mapkit.map.IconStyle;
import com.yandex.mapkit.map.RotationType;
import com.yandex.mapkit.mapview.MapView;
import com.yandex.mapkit.user_location.UserLocationLayer;
import com.yandex.mapkit.user_location.UserLocationObjectListener;
Expand Down Expand Up @@ -65,10 +68,29 @@ public void onObjectAdded(UserLocationView userLocationView) {
new PointF((float)(mapView.getWidth() * 0.5), (float)(mapView.getHeight() * 0.5)),
new PointF((float)(mapView.getWidth() * 0.5), (float)(mapView.getHeight() * 0.83)));

userLocationView.getPin().setIcon(ImageProvider.fromResource(
this, R.drawable.user_arrow));
userLocationView.getArrow().setIcon(ImageProvider.fromResource(
this, R.drawable.user_arrow));

CompositeIcon pinIcon = userLocationView.getPin().useCompositeIcon();

pinIcon.setIcon(
"icon",
ImageProvider.fromResource(this, R.drawable.icon),
new IconStyle().setAnchor(new PointF(0f, 0f))
.setRotationType(RotationType.ROTATE)
.setZIndex(0f)
.setScale(1f)
);

pinIcon.setIcon(
"pin",
ImageProvider.fromResource(this, R.drawable.search_result),
new IconStyle().setAnchor(new PointF(0.5f, 0.5f))
.setRotationType(RotationType.ROTATE)
.setZIndex(1f)
.setScale(0.5f)
);

userLocationView.getAccuracyCircle().setFillColor(Color.BLUE);
}

Expand Down
Binary file added src/main/res/drawable/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f294fb9

Please sign in to comment.