forked from flutter-mapbox-gl/maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add line annotations (flutter-mapbox-gl#33)
* Add line Annotations * add line properties to examples * Add onLineTapped * change forEach to for * fix error in merge * fix methods order
- Loading branch information
Showing
13 changed files
with
803 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
android/src/main/java/com/mapbox/mapboxgl/LineBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// This file is generated. | ||
|
||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package com.mapbox.mapboxgl; | ||
|
||
import java.util.List; | ||
import com.mapbox.geojson.Point; | ||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
import com.mapbox.mapboxsdk.plugins.annotation.Line; | ||
import com.mapbox.mapboxsdk.plugins.annotation.LineManager; | ||
import com.mapbox.mapboxsdk.plugins.annotation.LineOptions; | ||
|
||
class LineBuilder implements LineOptionsSink { | ||
private final LineManager lineManager; | ||
private final LineOptions lineOptions; | ||
|
||
LineBuilder(LineManager lineManager) { | ||
this.lineManager = lineManager; | ||
this.lineOptions = new LineOptions(); | ||
} | ||
|
||
Line build() { | ||
return lineManager.create(lineOptions); | ||
} | ||
|
||
@Override | ||
public void setLineJoin(String lineJoin) { | ||
lineOptions.withLineJoin(lineJoin); | ||
} | ||
|
||
@Override | ||
public void setLineOpacity(float lineOpacity) { | ||
lineOptions.withLineOpacity(lineOpacity); | ||
} | ||
|
||
@Override | ||
public void setLineColor(String lineColor) { | ||
lineOptions.withLineColor(lineColor); | ||
} | ||
|
||
@Override | ||
public void setLineWidth(float lineWidth) { | ||
lineOptions.withLineWidth(lineWidth); | ||
} | ||
|
||
@Override | ||
public void setLineGapWidth(float lineGapWidth) { | ||
lineOptions.withLineGapWidth(lineGapWidth); | ||
} | ||
|
||
@Override | ||
public void setLineOffset(float lineOffset) { | ||
lineOptions.withLineOffset(lineOffset); | ||
} | ||
|
||
@Override | ||
public void setLineBlur(float lineBlur) { | ||
lineOptions.withLineBlur(lineBlur); | ||
} | ||
|
||
@Override | ||
public void setLinePattern(String linePattern) { | ||
lineOptions.withLinePattern(linePattern); | ||
} | ||
|
||
@Override | ||
public void setGeometry(List<LatLng> geometry) { | ||
lineOptions.withLatLngs(geometry); | ||
} | ||
|
||
@Override | ||
public void setDraggable(boolean draggable) { | ||
lineOptions.setDraggable(draggable); | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
android/src/main/java/com/mapbox/mapboxgl/LineController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// This file is generated. | ||
|
||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package com.mapbox.mapboxgl; | ||
|
||
import java.util.List; | ||
|
||
import android.graphics.PointF; | ||
import android.util.Log; | ||
|
||
import com.mapbox.geojson.Point; | ||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
import com.mapbox.mapboxsdk.plugins.annotation.Line; | ||
import com.mapbox.mapboxsdk.plugins.annotation.LineManager; | ||
import com.mapbox.mapboxsdk.utils.ColorUtils; | ||
|
||
/** | ||
* Controller of a single Line on the map. | ||
*/ | ||
class LineController implements LineOptionsSink { | ||
private final Line line; | ||
private final OnLineTappedListener onTappedListener; | ||
private boolean consumeTapEvents; | ||
|
||
LineController(Line line, boolean consumeTapEvents, OnLineTappedListener onTappedListener) { | ||
this.line = line; | ||
this.consumeTapEvents = consumeTapEvents; | ||
this.onTappedListener = onTappedListener; | ||
} | ||
|
||
boolean onTap() { | ||
if (onTappedListener != null) { | ||
onTappedListener.onLineTapped(line); | ||
} | ||
return consumeTapEvents; | ||
} | ||
|
||
void remove(LineManager lineManager) { | ||
lineManager.delete(line); | ||
} | ||
|
||
@Override | ||
public void setLineJoin(String lineJoin) { | ||
line.setLineJoin(lineJoin); | ||
} | ||
|
||
@Override | ||
public void setLineOpacity(float lineOpacity) { | ||
line.setLineOpacity(lineOpacity); | ||
} | ||
|
||
@Override | ||
public void setLineColor(String lineColor) { | ||
line.setLineColor(ColorUtils.rgbaToColor(lineColor)); | ||
} | ||
|
||
@Override | ||
public void setLineWidth(float lineWidth) { | ||
line.setLineWidth(lineWidth); | ||
} | ||
|
||
@Override | ||
public void setLineGapWidth(float lineGapWidth) { | ||
line.setLineGapWidth(lineGapWidth); | ||
} | ||
|
||
@Override | ||
public void setLineOffset(float lineOffset) { | ||
line.setLineOffset(lineOffset); | ||
} | ||
|
||
@Override | ||
public void setLineBlur(float lineBlur) { | ||
line.setLineBlur(lineBlur); | ||
} | ||
|
||
@Override | ||
public void setLinePattern(String linePattern) { | ||
line.setLinePattern(linePattern); | ||
} | ||
|
||
@Override | ||
public void setGeometry(List<LatLng> geometry) { | ||
line.setLatLngs(geometry); | ||
} | ||
|
||
@Override | ||
public void setDraggable(boolean draggable) { | ||
line.setDraggable(draggable); | ||
} | ||
|
||
public void update(LineManager lineManager) { | ||
lineManager.update(line); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
android/src/main/java/com/mapbox/mapboxgl/LineOptionsSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// This file is generated. | ||
|
||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package com.mapbox.mapboxgl; | ||
|
||
import java.util.List; | ||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
|
||
/** | ||
* Receiver of Line configuration options. | ||
*/ | ||
interface LineOptionsSink { | ||
|
||
void setLineJoin(String lineJoin); | ||
|
||
void setLineOpacity(float lineOpacity); | ||
|
||
void setLineColor(String lineColor); | ||
|
||
void setLineWidth(float lineWidth); | ||
|
||
void setLineGapWidth(float lineGapWidth); | ||
|
||
void setLineOffset(float lineOffset); | ||
|
||
void setLineBlur(float lineBlur); | ||
|
||
void setLinePattern(String linePattern); | ||
|
||
void setGeometry(List<LatLng> geometry); | ||
|
||
void setDraggable(boolean draggable); | ||
} |
Oops, something went wrong.