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 13989 map long click #13

Merged
merged 4 commits into from
Oct 5, 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.
3 changes: 2 additions & 1 deletion android/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Change Log
<pre>
v2.1.3 Fixed memory leak when removing map instance from window [TIMOB-14772]

Added longClick event support [TIMOB-13989]

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].
Updated Google Play Services SDK.
Expand Down
21 changes: 20 additions & 1 deletion android/src/ti/map/TiUIMapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
import com.google.android.gms.maps.model.Marker;

public class TiUIMapView extends TiUIFragment implements GoogleMap.OnMarkerClickListener, GoogleMap.OnMapClickListener,
GoogleMap.OnCameraChangeListener, GoogleMap.OnMarkerDragListener, GoogleMap.OnInfoWindowClickListener, GoogleMap.InfoWindowAdapter
GoogleMap.OnCameraChangeListener, GoogleMap.OnMarkerDragListener, GoogleMap.OnInfoWindowClickListener, GoogleMap.InfoWindowAdapter,
GoogleMap.OnMapLongClickListener
{
private static final String TAG = "TiUIMapView";
private GoogleMap map;
Expand Down Expand Up @@ -75,6 +76,7 @@ protected void onViewCreated()
map.setOnMarkerDragListener(this);
map.setOnInfoWindowClickListener(this);
map.setInfoWindowAdapter(this);
map.setOnMapLongClickListener(this);
((ViewProxy) proxy).clearPreloadObjects();
proxy.fireEvent(TiC.EVENT_COMPLETE, null);
}
Expand Down Expand Up @@ -416,6 +418,17 @@ public void fireClickEvent(Marker marker, AnnotationProxy annoProxy, String clic
d.put(TiC.EVENT_PROPERTY_CLICKSOURCE, clickSource);
proxy.fireEvent(TiC.EVENT_CLICK, d);
}

public void fireLongClickEvent(LatLng point)
{
KrollDict d = new KrollDict();
d.put(TiC.PROPERTY_LATITUDE, point.latitude);
d.put(TiC.PROPERTY_LONGITUDE, point.longitude);
d.put(MapModule.PROPERTY_MAP, proxy);
d.put(TiC.PROPERTY_TYPE, TiC.EVENT_LONGCLICK);
d.put(TiC.PROPERTY_SOURCE, proxy);
proxy.fireEvent(TiC.EVENT_LONGCLICK, d);
}

public void firePinChangeDragStateEvent(Marker marker, AnnotationProxy annoProxy, int dragState)
{
Expand Down Expand Up @@ -465,6 +478,12 @@ public void onMapClick(LatLng point)
}

}

@Override
public void onMapLongClick(LatLng point)
{
fireLongClickEvent(point);
}

@Override
public void onMarkerDrag(Marker marker)
Expand Down
27 changes: 26 additions & 1 deletion apidoc/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ description: |

extends: Titanium.UI.View
excludes: {
events: [ 'singletap', 'doubletap', 'dblclick', 'longclick', 'longpress', 'pinch',
events: [ 'singletap', 'doubletap', 'dblclick', 'longpress', 'pinch',
'swipe', 'touchstart', 'touchend', 'touchcancel', 'touchmove', 'twofingertap' ]
}
since: "3.0.2"
Expand Down Expand Up @@ -232,6 +232,31 @@ events:
type: Number
since: "3.1.1"

- name: longclick
summary: |
Fired when the user makes a long-press gesture on the map.
description: |
A long press is generated by touching and holding on the touch screen.

The event occurs before the finger/button is lifted.

The `longclick` event returns longitude and latitude of the point on the ground that was pressed.
since: "3.2.0"

properties:

- name: latitude
summary: latitude of the point on the ground that was pressed.
type: Number

- name: longitude
summary: longitude of the point on the ground that was pressed.
type: Number

- name: map
summary: The map view instance.
type: Modules.Map.View

properties:

- name: animate
Expand Down