Does anyone know if you can change the compass position within the map?
All I can find is how to enable or disable it. But I need to move it down a bit so my overlay is not obstructing it.
Open the Google Maps app, making sure that your blue circular device location icon is in view. Tap on the location icon to bring up more information about your location. At the bottom, tap the “Calibrate Compass” button. This will bring up the compass calibration screen.
The compass appears as a widget on the right-hand side of the map screen, with a red arrow determinedly pointing north on the map as you rotate your phone.
Long press the marker to enable dragging. When you take your finger off the screen, the marker will remain in that position. Markers are not draggable by default. You must explicitly set the marker to be draggable either with MarkerOptions.
Where to Find the Compass in Google Maps for Android. If you are running Google Maps 10.62 or a newer build on your Android device, you should see the compass widget in the Navigation screen right below the volume button. The compass widget will only show up when using navigation in Google Maps.
Use GoogleMap.setPadding() method:
https://developers.google.com/maps/documentation/android/map#map_padding
@Override public void onMapReady(GoogleMap map) { try { final ViewGroup parent = (ViewGroup) mMapView.findViewWithTag("GoogleMapMyLocationButton").getParent(); parent.post(new Runnable() { @Override public void run() { try { Resources r = getResources(); //convert our dp margin into pixels int marginPixels = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, r.getDisplayMetrics()); // Get the map compass view View mapCompass = parent.getChildAt(4); // create layoutParams, giving it our wanted width and height(important, by default the width is "match parent") RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(mapCompass.getHeight(),mapCompass.getHeight()); // position on top right rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); //give compass margin rlp.setMargins(marginPixels, marginPixels, marginPixels, marginPixels); mapCompass.setLayoutParams(rlp); } catch (Exception ex) { ex.printStackTrace(); } } }); } catch (Exception ex) { ex.printStackTrace(); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With