https://github.com/steveleetn91/vnnative3-geolocation
https://github.com/steveleetn91/vnnative3-geolocation
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/steveleetn91/vnnative3-geolocation
- Owner: steveleetn91
- License: apache-2.0
- Created: 2022-04-02T13:39:52.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-03T10:49:17.000Z (about 3 years ago)
- Last Synced: 2025-02-04T08:03:20.376Z (5 months ago)
- Language: TypeScript
- Size: 3.48 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vnnative3-geolocation
This is a plugin support Geolocation for Vn Native 3. Default support for `Web` and `Software`, and if you wanna
support for `Android` and `iOS`, so need install more cordova plugin.## How to install ?
npm i vnnative3-geolocation
Next step go to `./node_modules/vnnative3-geolocation` and run :
npm install
Next
npm run build
## Support Android and iOS
cordova plugin add cordova-plugin-geolocation
## Setup HTML
## Quick start
// import
import Vnnative3Geolocation from 'vnnative3-geolocation';
import { Vnnative3GeolocationResponse, Vnnative3GeolocationResponseError, Vnnative3GoogleMapServiceInterface } from 'vnnative3-geolocation/dist/libs/Vnnative3GeolocationBase.interface';
// uselet position : Vnnative3GeolocationResponse;
Vnnative3Geolocation.getCurrentPosition((resp : Vnnative3GeolocationResponse) => {
position = resp;
const GoogleMapWebServiceKey : string = "";
Vnnative3Geolocation.useGoogleMap(GoogleMapWebServiceKey,"map",(map : Vnnative3GoogleMapServiceInterface) => {
map.setCamera({
lat : position.coords.latitude,
lng : position.coords.longitude
});map.setZoom(20);
// add marker
let marker : google.maps.Marker = map.addMarker({
lat : position.coords.latitude,
lng : position.coords.longitude
});marker.setMap(map.map);
// marker.setVisible(false ? true);
// view more about marker
// https://developers.google.com/maps/documentation/javascript/markers#maps_marker_simple-typescript
});
},(resp : Vnnative3GeolocationResponseError) => {});
## Get current position ?
Vnnative3Geolocation.getCurrentPosition(successCallback,errorCallback)
### Google Map
const callback = (map : Vnnative3GoogleMapServiceInterface) => {
console.log(map);
}Vnnative3Geolocation.useGoogleMap(googleMapWebKey: string, canvas_id: string,callback);
## Watch position ?
const timeCheck : number = 3000;
const watchId : number = Vnnative3Geolocation.watchPosition(successCallback,errorCallback,timeCheck);## Destroy watch position ?
Vnnative3Geolocation.clearWatch(watchId);