Coder Social home page Coder Social logo

Comments (8)

Stavanger75 avatar Stavanger75 commented on May 17, 2024 4

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.

dapriett avatar dapriett commented on May 17, 2024 1

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.

ickata avatar ickata commented on May 17, 2024 1

I confirm that the example is working on my side.

Thanks, @Stavanger75 !

from nativescript-google-maps-sdk.

ickata avatar ickata commented on May 17, 2024

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.

Stavanger75 avatar Stavanger75 commented on May 17, 2024

+1

from nativescript-google-maps-sdk.

elpin1988 avatar elpin1988 commented on May 17, 2024

How I do add input autocomplete directions to mapview with angular and typescript on nativescript?

from nativescript-google-maps-sdk.

Aks659 avatar Aks659 commented on May 17, 2024

@Stavanger75 .
For me mapView.android is throwing error.
So, I am using platform.isAndroid instead.

from nativescript-google-maps-sdk.

MrSinaRJ avatar MrSinaRJ commented on May 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.