Is it possible to handle My Location and My Location button separately?
See original GitHub issueI’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:
- Created 6 years ago
- Reactions:1
- Comments:12 (9 by maintainers)
Top GitHub Comments
Ok, I managed to implement the myLocation and the myLocationButton option finally.
Try like this with the multiple_maps branch version.
Thanks, I will then continue fork your code with every new release. You might want to close this request. Thanks again.