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

timob-12787: Added support for showInfoWindow #15

Merged
merged 3 commits into from
Oct 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified android/dist/ti.map-android-2.1.3.zip
Binary file not shown.
1 change: 1 addition & 0 deletions android/documentation/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<pre>
v2.1.3 Fixed memory leak when removing map instance from window [TIMOB-14772]
Added longClick event support [TIMOB-13989]
Added support for showInfoWindow property for annotations [TIMOB-12787]

v2.1.2 Clicking on an annotation should center it in map view [TIMOB-13778].
Fixed a bug where removing an annotation using its title crashed the app [TIMOB-14502].
Expand Down
5 changes: 4 additions & 1 deletion android/src/ti/map/AnnotationProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
TiC.PROPERTY_LEFT_BUTTON,
TiC.PROPERTY_LEFT_VIEW,
TiC.PROPERTY_RIGHT_BUTTON,
TiC.PROPERTY_RIGHT_VIEW
TiC.PROPERTY_RIGHT_VIEW,
MapModule.PROPERTY_SHOW_INFO_WINDOW
})
public class AnnotationProxy extends KrollProxy
{
Expand All @@ -71,6 +72,7 @@ public AnnotationProxy()
super();
markerOptions = new MarkerOptions();
annoTitle = "";
defaultValues.put(MapModule.PROPERTY_SHOW_INFO_WINDOW, true);
}

public AnnotationProxy(TiContext tiContext)
Expand Down Expand Up @@ -139,6 +141,7 @@ public void processOptions()
{
double longitude = 0;
double latitude = 0;

if (hasProperty(TiC.PROPERTY_LONGITUDE)) {
longitude = TiConvert.toDouble(getProperty(TiC.PROPERTY_LONGITUDE));
}
Expand Down
1 change: 1 addition & 0 deletions android/src/ti/map/MapModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class MapModule extends KrollModule
public static final String PROPERTY_INFO_WINDOW = "infoWindow";
public static final String PROPERTY_LEFT_PANE = "leftPane";
public static final String PROPERTY_RIGHT_PANE = "rightPane";
public static final String PROPERTY_SHOW_INFO_WINDOW = "showInfoWindow";
public static final String PROPERTY_USER_LOCATION_BUTTON = "userLocationButton";
public static final String EVENT_PIN_CHANGE_DRAG_STATE = "pinchangedragstate";

Expand Down
11 changes: 8 additions & 3 deletions android/src/ti/map/TiUIMapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,15 @@ public boolean onMarkerClick(Marker marker)
fireClickEvent(marker, annoProxy, MapModule.PROPERTY_PIN);
return true;
}

selectedAnnotation = annoProxy;
fireClickEvent(marker, annoProxy, MapModule.PROPERTY_PIN);
return false;
selectedAnnotation = annoProxy;
boolean showInfoWindow = TiConvert.toBoolean(annoProxy.getProperty(MapModule.PROPERTY_SHOW_INFO_WINDOW), true);
//Returning false here will enable native behavior, which shows the info window.
if (showInfoWindow) {
return false;
} else {
return true;
}
}

@Override
Expand Down
14 changes: 13 additions & 1 deletion apidoc/Annotation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,16 @@ properties:
description: |
This is ignored if the `rightButton` property is set.
type: Titanium.UI.View
since: "3.1.0"
since: "3.1.0"

- name: showInfoWindow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On iOS, this property is called "canShowCallout" (see https://jira.appcelerator.org/browse/TIMOB-12479). We should keep the property name the same for parity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a module, and callout doesn't mean anything to Android. I spoke with Vishal and he said its ok if I rename the property.

summary: Show or hide the view that is displayed on the annotation when clicked.
description: |
When this is false, clicking on the annotation will not center it on the map, but the
annotation will still be selected, thus triggering the click event.
If the annotation is selected, and the info window is hidden, then the next click
will deselect the annotation, thus will NOT show the info window, regardless of the current state of this property.
type: Boolean
default: true
since: "3.2.0"

8 changes: 5 additions & 3 deletions apidoc/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,15 @@ events:

- name: click
summary: |
Fired when the user selects, deselects, or clicks on an annotation.
Fired when the user selects or deselects an annotation.
description: |
Note that the `click` event is not fired every time the user clicks on the map.
It is fired in two circumstances:

- If the user clicks on an annotation to select it.
- The user deselects an annotation.
- The user clicks on the annotation. This will select the annotation.
- The user deselects an annotation either by clicking on the map or another annotation.

Note that only one annotation can be selected at any given time.

The `click` event includes a value, `clicksource`, which describes the part of the
annotation that was clicked. The `clicksource` can be one of `pin`, `title`,
Expand Down