question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to handle My Location and My Location button separately?

See original GitHub issue

I’m submitting a … (check one with “x”) [ ] question [ ] any problem or bug report [x] feature request

If you choose ‘problem or bug report’, please select OS: (check one with “x”) [x] Android [x] iOS

cordova information: (run $> cordova plugin list)

com.googlemaps.ios 2.5.0 "Google Maps SDK for iOS"
cordova-plugin-googlemaps 2.1.1 "cordova-plugin-googlemaps"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)@ionic-native/core”: “4.5.2”,
@ionic-native/google-maps”: “4.5.2”

Current behavior: Currently, setMyLocationEnabled() both enables/disables the my location layer with the blue dot and the gray button on the map.

In PluginMap.m (IOS):

(void)setMyLocationEnabled:(CDVInvokedUrlCommand *)command {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];		      
self.mapCtrl.map.settings.myLocationButton = isEnabled;
self.mapCtrl.map.myLocationEnabled = isEnabled;
    }];		    }];

In PluginMap.java (Android)

  final Boolean isEnabled = args.getBoolean(0);
    this.activity.runOnUiThread(new Runnable() {
      @Override
      public void run() {
        try {
          map.setMyLocationEnabled(isEnabled);
        } catch (SecurityException e) {
          e.printStackTrace();
        }
        map.getUiSettings().setMyLocationButtonEnabled(false);
        callbackContext.success();
      }
    });	

I’m wondering if it was possible to support the my location layer without actually displaying the button. It is because the grey button is rather big and it does not blend into the style of most applications. Eg. I would like to put my location button in the menu bar instead.

At the moment I need to fork this repo and manually remove the button every time you have a new release, hence the request.

Great plugin otherwise, thank you for your work.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
wf9a5m75commented, Jan 26, 2018

Ok, I managed to implement the myLocation and the myLocationButton option finally.

Try like this with the multiple_maps branch version.

plugin.google.maps.Map.getMap(mapDiv, {
  controls: {
    myLocation: true,
    myLocationButton: false
  }
});
1reaction
battikacommented, Dec 19, 2017

Thanks, I will then continue fork your code with every new release. You might want to close this request. Thanks again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix a missing address or wrong pin location - Google Maps Help
Enter the address information. To submit, tap Post. To fix multiple addresses: You must add each address individually with the steps above. Make...
Read more >
My location button event listener - android - Stack Overflow
Set an onClickListener to this button and animate the map to the map's location. This is no longer true, Android has updated.
Read more >
Controls and Gestures | Maps SDK for Android
The My Location button appears in the top right corner of the screen only when the My Location layer is enabled. For details,...
Read more >
How to Share Your Location in Google Maps | PCMag
Before you can start sharing location data, you must first enable the feature in the Google Maps app. Tap your profile icon in...
Read more >
Windows location service and privacy - Microsoft Support
For the Allow location override setting to work, the Location services setting for both the local and remote devices needs to be turned...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found