diff --git a/README.md b/README.md index 0934af0..330c28c 100755 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ exports.onMapReady = onMapReady; ``` The methods you can invoke like this from an XML-declared map are: -`addMarkers`, `setViewport`, `removeMarkers`, `getCenter`, `setCenter`, `getZoomLevel`, `setZoomLevel`, `getViewport`, `getTilt`, `setTilt`, `setMapStyle`, `animateCamera`, `addPolygon`, `removePolygons`, `addPolyline`, `removePolylines`, `getUserLocation`, `trackUser`, `setOnMapClickListener` and `destroy`. +`addMarkers`, `setViewport`, `removeMarkers`, `getCenter`, `setCenter`, `getZoomLevel`, `setZoomLevel`, `getViewport`, `getTilt`, `setTilt`, `setMapStyle`, `animateCamera`, `addPolygon`, `removePolygons`, `addPolyline`, `removePolylines`, `getUserLocation`, `trackUser`, `setOnMapClickListener`, `setOnMapLongClickListener` and `destroy`. Check out the usage details on the functions below. @@ -571,6 +571,15 @@ Add a listener to retrieve lat and lng of where the user taps the map (not a mar }); ``` +### setOnMapLongClickListener +Add a listener to retrieve lat and lng of where the user longpresses the map (not a marker). + +```typescript + mapbox.setOnMapLongClickListener((point: LatLng) => { + console.log("Map longpressed at latitude: " + point.lat + ", longitude: " + point.lng); + }); +``` + ### setOnScrollListener Add a listener to retrieve lat and lng of where the user scrolls to on the map. diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts index 5123b27..a678433 100644 --- a/demo/app/main-page.ts +++ b/demo/app/main-page.ts @@ -29,6 +29,8 @@ function onMapReady(args) { map.setOnMapClickListener((point: LatLng) => console.log(`Map tapped: ${JSON.stringify(point)}`)); + map.setOnMapLongClickListener((point: LatLng) => console.log(`Map longpressed: ${JSON.stringify(point)}`)); + // this works perfectly fine, but generates a lot of noise // map.setOnScrollListener((point?: LatLng) => console.log(`Map scrolled: ${JSON.stringify(point)}`)); diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts index b1b318d..7673c7d 100644 --- a/demo/app/main-view-model.ts +++ b/demo/app/main-view-model.ts @@ -56,6 +56,8 @@ export class HelloWorldModel extends Observable { this.mapbox.setOnMapClickListener(point => console.log(`>> Map clicked: ${JSON.stringify(point)}`)); + this.mapbox.setOnMapLongClickListener(point => console.log(`>> Map longpressed: ${JSON.stringify(point)}`)); + this.mapbox.setOnScrollListener((point: LatLng) => { // console.log(`>> Map scrolled: ${JSON.stringify(point)}`); }); diff --git a/src/mapbox.ios.ts b/src/mapbox.ios.ts index 5c3534b..bbdaaa7 100755 --- a/src/mapbox.ios.ts +++ b/src/mapbox.ios.ts @@ -1250,6 +1250,7 @@ class MapLongPressHandlerImpl extends NSObject { "longPress": {returns: interop.types.void, params: [interop.types.id]} }; } + class MapPanHandlerImpl extends NSObject { private _owner: WeakRef; private _listener: (data?: LatLng) => void; diff --git a/src/package-lock.json b/src/package-lock.json index 0657a02..8a1daf3 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,6 +1,6 @@ { "name": "nativescript-mapbox", - "version": "4.3.0", + "version": "4.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -22,7 +22,7 @@ "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", "dev": true, "requires": { - "sprintf-js": "~1.0.2" + "sprintf-js": "1.0.3" } }, "babel-code-frame": { @@ -77,7 +77,7 @@ "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", "dev": true, "requires": { - "color-name": "^1.1.1" + "color-name": "1.1.3" } }, "color-name": { @@ -173,8 +173,8 @@ "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "1.0.10", + "esprima": "4.0.0" } }, "minimatch": { @@ -255,18 +255,18 @@ "integrity": "sha1-EeJrzLiK+gLdDZlWyuPUVAtfVMM=", "dev": true, "requires": { - "babel-code-frame": "^6.22.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^3.2.0", - "glob": "^7.1.1", - "js-yaml": "^3.7.0", - "minimatch": "^3.0.4", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.12.1" + "babel-code-frame": "6.26.0", + "builtin-modules": "1.1.1", + "chalk": "2.4.1", + "commander": "2.15.1", + "diff": "3.5.0", + "glob": "7.1.2", + "js-yaml": "3.11.0", + "minimatch": "3.0.4", + "resolve": "1.7.1", + "semver": "5.5.0", + "tslib": "1.9.2", + "tsutils": "2.27.1" }, "dependencies": { "ansi-styles": { @@ -275,7 +275,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "^1.9.0" + "color-convert": "1.9.1" } }, "chalk": { @@ -284,9 +284,9 @@ "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" } }, "commander": { @@ -307,7 +307,7 @@ "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "1.0.5" } }, "semver": { @@ -322,7 +322,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } }, "tslib": { @@ -337,7 +337,7 @@ "integrity": "sha512-AE/7uzp32MmaHvNNFES85hhUDHFdFZp6OAiZcd6y4ZKKIg6orJTm8keYWBhIhrJQH3a4LzNKat7ZPXZt5aTf6w==", "dev": true, "requires": { - "tslib": "^1.8.1" + "tslib": "1.9.2" } } } diff --git a/src/package.json b/src/package.json index dd84b4c..0d5d34c 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-mapbox", - "version": "4.3.0", + "version": "4.3.1", "description": "Native Maps, by Mapbox.", "main": "mapbox", "typings": "index.d.ts",