Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow usage of a custom MyLocationOverlay #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion library/src/com/cyrilmottier/polaris/PolarisMapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ public boolean isUserTrackingButtonEnabled() {
* @param enabled True if user tracking is enabled, false otherwise.
*/
public void setUserTrackingButtonEnabled(boolean enabled) {
setUserTrackingButtonEnabled(enabled, null);
}

/**
* Enable/disable user tracking on this {@link PolarisMapView}.
*
* @param enabled True if user tracking is enabled, false otherwise.
* @param customOverlay An object from a custom class inheriting from MyLocationOverlay, ignored if enabled is false.
*/
public void setUserTrackingButtonEnabled(boolean enabled, MyLocationOverlay customOverlay) {
if (mIsUserTrackingButtonEnabled != enabled) {
mIsUserTrackingButtonEnabled = enabled;
if (enabled) {
Expand All @@ -530,7 +540,14 @@ public void setUserTrackingButtonEnabled(boolean enabled) {
);
//@formatter:on
}
mMyLocationOverlay = new MyLocationOverlay(getContext(), this);
if (customOverlay == null)
{
mMyLocationOverlay = new MyLocationOverlay(getContext(), this);
}
else
{
mMyLocationOverlay = customOverlay;
}
mMyLocationOverlay.enableMyLocation();
mOverlayContainer.setUserLocationOverlay(mMyLocationOverlay);
addView(mUserTrackingButton);
Expand Down