Comments (8)
Hi,
I got this code to work on android and ios. Hope it helps.
mapView = args.object;
var gMap = mapView.gMap;
if(mapView.android) {
uiSettings = gMap.getUiSettings();
uiSettings.setMyLocationButtonEnabled(true);
gMap.setMyLocationEnabled(true);
}
if (mapView.ios) {
gMap.myLocationEnabled = true;
gMap.settings.myLocationButton = true;
}
Here is a more complete sample. (not tested). Sorry for the bad formating of the code under.
//Plugin from : https://github.com/NathanaelA/nativescript-permissions
var permissions = require('nativescript-permissions');
exports.onMapReady(args){
mapView = args.object;
var gMap = mapView.gMap;
//Application request the location permission
permissions.requestPermission(android.Manifest.permission.ACCESS_FINE_LOCATION, "I need these permissions because I'm cool")
.then(function() {
console.log("Woo Hoo, I have the power!");
if(mapView.android) {
uiSettings = gMap.getUiSettings();
uiSettings.setMyLocationButtonEnabled(true);
gMap.setMyLocationEnabled(true);
}
if(mapView.ios) {
gMap.myLocationEnabled = true;
gMap.settings.myLocationButton = true;
}
})
.catch(function() {
console.log("Uh oh, no permissions - plan B time!");
});
}
from nativescript-google-maps-sdk.
I believe you enable my location
function onMapReady(args) {
var mapView = args.object;
var gMap = mapView.gMap;
if(mapView.android) {
gMap.setMyLocationEnabled(true);
}
if (mapView.ios) {
gMap.myLocationEnabled(true);
}
}
from nativescript-google-maps-sdk.
I confirm that the example is working on my side.
Thanks, @Stavanger75 !
from nativescript-google-maps-sdk.
Not exactly. This is how I enable it:
if (mapView.ios) {
gMap.myLocationEnabled = true;
}
In iOS myLocationEnabled
is a property (Boolean), not a method.
Also this only shows the blue dot where your location is. What I want is to display the button at the bottom-right corner, which when pressed moves the map camera to your location. I am sure that this is possible with GMaps API since there is another nativescript-googlemaps plugin which does this by default. But your plugin has more rich API :)
from nativescript-google-maps-sdk.
+1
from nativescript-google-maps-sdk.
How I do add input autocomplete directions to mapview with angular and typescript on nativescript?
from nativescript-google-maps-sdk.
@Stavanger75 .
For me mapView.android
is throwing error.
So, I am using platform.isAndroid
instead.
from nativescript-google-maps-sdk.
I got the map working like mentioned by @Stavanger75 , BUT something very weird is going on here!
ActivityManager: Start proc 25860:org.nativescript.MapTest/u0a298 for activity org.nativescript.MapTest/com.tns.NativeScriptActivity
JS: Woo Hoo, I have the power!
JS: Uh oh, no permissions - plan B time!
how is that possible that console.log prints .then
and .catch
body!!!!
Am i missing something or something is wrong here?!
from nativescript-google-maps-sdk.
Related Issues (20)
- infoWindow open without a click event HOT 2
- Blank Map with Angular in Suspend/Resume Event HOT 1
- Angular Map not drawing Polylines HOT 6
- shape.loadPoints is not a function?
- Geo political features
- Nativescript 6.0 error maps arr HOT 16
- Conflicts with @triniwiz/nativescript-image-cache-it HOT 1
- Performance Angular? HOT 1
- NS8 infoWindowTemplate is not working HOT 1
- Gesture Handling Cooperative HOT 2
- Gradle 7 requires that compile be changed to implementation
- iOS + M1 - not works HOT 3
- Failed to build plugin nativescript-google-maps-sdk HOT 1
- How to set a pattern in a shape HOT 2
- Version of Google Map API HOT 2
- How to set a tag in shapes or markers HOT 1
- Adding GroundOverlays HOT 1
- Could not find method compile() for arguments [com.google.android.gms:play-services-maps:+] HOT 3
- Uncaught ReferenceError: NativeClass is not defined HOT 3
- Class constructor ActionItem cannot be invoked without 'new' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-google-maps-sdk.