6 package com.google.appinventor.components.runtime;
28 import org.locationtech.jts.geom.Geometry;
29 import org.osmdroid.util.GeoPoint;
35 private boolean visible =
true;
37 private float strokeOpacity = 1;
38 private int strokeWidth = 1;
39 private String title =
"";
40 private String description =
"";
41 private boolean draggable =
false;
42 private boolean infobox =
false;
43 private GeoPoint centroid =
null;
47 public Double visit(
MapMarker marker, Object... arguments) {
52 public Double visit(
MapLineString lineString, Object... arguments) {
53 if ((Boolean) arguments[1]) {
61 public Double visit(
MapPolygon polygon, Object... arguments) {
62 if ((Boolean) arguments[1]) {
70 public Double visit(
MapCircle circle, Object... arguments) {
71 if ((Boolean) arguments[1]) {
79 public Double visit(
MapRectangle rectangle, Object... arguments) {
80 if ((Boolean) arguments[1]) {
92 private Geometry geometry =
null;
94 @SuppressWarnings(
"WeakerAccess")
99 this.distanceComputation = distanceComputation;
119 @SuppressWarnings(
"squid:S00100")
121 defaultValue =
"True")
124 if (visible == visibility) {
127 this.visible = visibility;
141 description =
"Specifies whether the %type% should be visible on the screen. "
142 +
"Value is true if the component is showing and false if hidden.")
161 description =
"The paint color used to outline the %type%.")
169 defaultValue =
"1.0")
172 strokeOpacity = opacity;
173 strokeColor = (strokeColor & 0x00FFFFFF) | (Math.round(0xFF * opacity) << 24);
183 description =
"The opacity of the stroke used to outline the map feature.")
185 return strokeOpacity;
202 description =
"The width of the stroke used to outline the %type%.")
209 defaultValue =
"False")
212 this.draggable = draggable;
221 @
SimpleProperty(description =
"The Draggable property is used to set whether or not the user " +
222 "can drag the %type% by long-pressing and then dragging the %type% to a new location.")
224 return this.draggable;
241 description =
"The title displayed in the info window that appears when the user clicks " +
251 this.description = description;
261 description =
"The description displayed in the info window that appears when the user " +
262 "clicks on the %type%.")
269 defaultValue =
"False")
272 this.infobox = enable;
281 description =
"Enable or disable the infobox window display when the user taps the %type%.")
291 @
SimpleFunction(description =
"Show the infobox for the %type%. This will show the infobox " +
292 "even if EnableInfobox is set to false.")
301 @
SimpleFunction(description =
"Hide the infobox if it is shown. If the infobox is not " +
302 "visible this function has no effect.")
307 @SuppressWarnings(
"squid:S00100")
326 @SuppressWarnings(
"squid:S00100")
327 @
SimpleFunction(description =
"Compute the distance, in meters, between a %type% and a " +
328 "latitude, longitude point.")
330 return accept(distanceToPoint,
new GeoPoint(latitude, longitude), centroid);
345 @SuppressWarnings(
"squid:S00100")
346 @
SimpleFunction(description =
"Compute the distance, in meters, between two map features.")
348 return mapFeature ==
null ? -1 : mapFeature.accept(distanceComputation,
this, centroids);
357 @
SimpleEvent(description =
"The user clicked on the %type%.")
369 @
SimpleEvent(description =
"The user long-pressed on the %type%. This event will only " +
370 "trigger if Draggable is false.")
382 @
SimpleEvent(description =
"The user started a drag operation.")
392 @
SimpleEvent(description =
"The user dragged the %type%.")
402 @
SimpleEvent(description =
"The user stopped a drag operation.")
415 if (centroid ==
null) {
423 if (geometry ==
null) {
429 @SuppressWarnings(
"WeakerAccess")