Skip to content

Commit a7e36d3

Browse files
committed
[annotation] - add geojson compatible api
1 parent 2a4bedd commit a7e36d3

10 files changed

Lines changed: 165 additions & 0 deletions

File tree

plugin-annotation/scripts/annotation.java.ejs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,46 @@ public class <%- camelize(type) %> extends Annotation {
8888
geometry = Polygon.fromLngLats(points);
8989
}
9090
<% } -%>
91+
<% if (type === "circle" || type === "symbol") { -%>
92+
93+
/**
94+
* Set the Geometry of the <%- type %>, which represents the location of the <%- type %> on the map
95+
* <p>
96+
* To update the <%- type %> on the map use {@link <%- camelize(type) %>Manager#update(Annotation)}.
97+
* <p>
98+
*
99+
* @param geometry the geometry of the <%- type %>
100+
*/
101+
public void setGeometry(Point geometry) {
102+
this.geometry = geometry;
103+
}
104+
<% } else if (type === "line") { -%>
105+
106+
/**
107+
* Set the Geometry of the <%- type %>, which represents the location of the <%- type %> on the map
108+
* <p>
109+
* To update the <%- type %> on the map use {@link <%- camelize(type) %>Manager#update(Annotation)}.
110+
* <p>
111+
*
112+
* @param geometry the geometry of the <%- type %>
113+
*/
114+
public void setGeometry(LineString geometry) {
115+
this.geometry = geometry;
116+
}
117+
<% } else { -%>
118+
119+
/**
120+
* Set the Geometry of the <%- type %>, which represents the location of the <%- type %> on the map
121+
* <p>
122+
* To update the <%- type %> on the map use {@link <%- camelize(type) %>Manager#update(Annotation)}.
123+
* <p>
124+
*
125+
* @param geometry the geometry of the <%- type %>
126+
*/
127+
public void setGeometry(Polygon geometry) {
128+
this.geometry = geometry;
129+
}
130+
<% } -%>
91131
<% if (type === "symbol") { -%>
92132
93133
///**

plugin-annotation/scripts/annotation_options.java.ejs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
6666
geometry = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
6767
return this;
6868
}
69+
70+
/**
71+
* Set the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
72+
*
73+
* @param geometry the location of the <%- type %>
74+
* @return this
75+
*/
76+
public <%- camelize(type) %>Options withGeometry(Point geometry) {
77+
this.geometry = geometry;
78+
return this;
79+
}
6980
<% } else if (type === "line") { -%>
7081
7182
/**
@@ -82,6 +93,17 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
8293
geometry = LineString.fromLngLats(points);
8394
return this;
8495
}
96+
97+
/**
98+
* Set the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
99+
*
100+
* @param geometry the location of the <%- type %>
101+
* @return this
102+
*/
103+
public <%- camelize(type) %>Options withGeometry(LineString geometry) {
104+
this.geometry = geometry;
105+
return this;
106+
}
85107
<% } else { -%>
86108
87109
/**
@@ -102,6 +124,17 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
102124
geometry = Polygon.fromLngLats(points);
103125
return this;
104126
}
127+
128+
/**
129+
* Set the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
130+
*
131+
* @param geometry the location of the <%- type %>
132+
* @return this
133+
*/
134+
public <%- camelize(type) %>Options withGeometry(Polygon geometry) {
135+
this.geometry = geometry;
136+
return this;
137+
}
105138
<% } -%>
106139

107140
@Override

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Circle.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ public void setLatLng(LatLng latLng) {
3838
geometry = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
3939
}
4040

41+
/**
42+
* Set the Geometry of the circle, which represents the location of the circle on the map
43+
* <p>
44+
* To update the circle on the map use {@link CircleManager#update(Annotation)}.
45+
* <p>
46+
*
47+
* @param geometry the geometry of the circle
48+
*/
49+
public void setGeometry(Point geometry) {
50+
this.geometry = geometry;
51+
}
52+
4153
// Property accessors
4254
/**
4355
* Get the CircleRadius property

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/CircleOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ public CircleOptions withLatLng(LatLng latLng) {
179179
return this;
180180
}
181181

182+
/**
183+
* Set the geometry of the circle, which represents the location of the circle on the map
184+
*
185+
* @param geometry the location of the circle
186+
* @return this
187+
*/
188+
public CircleOptions withGeometry(Point geometry) {
189+
this.geometry = geometry;
190+
return this;
191+
}
192+
182193
@Override
183194
Circle build(long id) {
184195
if (geometry == null) {

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Fill.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ public void setLatLngs(List<List<LatLng>> latLngs) {
4646
geometry = Polygon.fromLngLats(points);
4747
}
4848

49+
/**
50+
* Set the Geometry of the fill, which represents the location of the fill on the map
51+
* <p>
52+
* To update the fill on the map use {@link FillManager#update(Annotation)}.
53+
* <p>
54+
*
55+
* @param geometry the geometry of the fill
56+
*/
57+
public void setGeometry(Polygon geometry) {
58+
this.geometry = geometry;
59+
}
60+
4961
// Property accessors
5062
/**
5163
* Get the FillOpacity property

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/FillOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ public FillOptions withLatLngs(List<List<LatLng>> latLngs) {
124124
return this;
125125
}
126126

127+
/**
128+
* Set the geometry of the fill, which represents the location of the fill on the map
129+
*
130+
* @param geometry the location of the fill
131+
* @return this
132+
*/
133+
public FillOptions withGeometry(Polygon geometry) {
134+
this.geometry = geometry;
135+
return this;
136+
}
137+
127138
@Override
128139
Fill build(long id) {
129140
if (geometry == null) {

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Line.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ public void setLatLngs(List<LatLng> latLngs) {
4242
geometry = LineString.fromLngLats(points);
4343
}
4444

45+
/**
46+
* Set the Geometry of the line, which represents the location of the line on the map
47+
* <p>
48+
* To update the line on the map use {@link LineManager#update(Annotation)}.
49+
* <p>
50+
*
51+
* @param geometry the geometry of the line
52+
*/
53+
public void setGeometry(LineString geometry) {
54+
this.geometry = geometry;
55+
}
56+
4557
// Property accessors
4658
/**
4759
* Get the LineJoin property

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/LineOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@ public LineOptions withLatLngs(List<LatLng> latLngs) {
204204
return this;
205205
}
206206

207+
/**
208+
* Set the geometry of the line, which represents the location of the line on the map
209+
*
210+
* @param geometry the location of the line
211+
* @return this
212+
*/
213+
public LineOptions withGeometry(LineString geometry) {
214+
this.geometry = geometry;
215+
return this;
216+
}
217+
207218
@Override
208219
Line build(long id) {
209220
if (geometry == null) {

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Symbol.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ public void setLatLng(LatLng latLng) {
4040
geometry = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
4141
}
4242

43+
/**
44+
* Set the Geometry of the symbol, which represents the location of the symbol on the map
45+
* <p>
46+
* To update the symbol on the map use {@link SymbolManager#update(Annotation)}.
47+
* <p>
48+
*
49+
* @param geometry the geometry of the symbol
50+
*/
51+
public void setGeometry(Point geometry) {
52+
this.geometry = geometry;
53+
}
54+
4355
///**
4456
// * Set the z-index of a symbol.
4557
// * <p>

plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/SymbolOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,17 @@ public SymbolOptions withLatLng(LatLng latLng) {
557557
return this;
558558
}
559559

560+
/**
561+
* Set the geometry of the symbol, which represents the location of the symbol on the map
562+
*
563+
* @param geometry the location of the symbol
564+
* @return this
565+
*/
566+
public SymbolOptions withGeometry(Point geometry) {
567+
this.geometry = geometry;
568+
return this;
569+
}
570+
560571
@Override
561572
Symbol build(long id) {
562573
if (geometry == null) {

0 commit comments

Comments
 (0)