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.

Android: mapView.zoom does not change zoom

See original GitHub issue

In my app, I want the map to zoom in to a default value whenever a marker is pressed. I referenced this issue and found that doing this.mapView.zoom = 15 within the onMarkerEvent works on iOS but not on Android. Is there another way to do this?

Also, I think it’s worth noting that changing the map’s center with this.mapView.latitude = ? and this.mapView.longitude = ? work on both Android and iOS.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

5reactions
jeffswitzercommented, Apr 2, 2018

I was able to get this to work by removing the angular bindings and just directly setting latitude, longitude and zoom on the MapView object.

So I removed

latitude="{{ latitude }}"
 longitude="{{ longitude }}"
 zoom="{{ zoomLvl }}"

from the following template:

<MapView #MapView
          latitude="{{ latitude }}"
          longitude="{{ longitude }}"
          zoom="{{ zoomLvl }}"
          bearing="{{ bearing }}"
          tilt="{{ tilt }}"
          i-padding="50,50,50,50"
          padding="{{ padding }}"
          (mapReady)="onMapReady($event)"
          (coordinateTapped)="onCoordinateTapped($event)"
          (cameraChanged)="onCameraChanged($event)"
          row="1" col="0"
          visibility="{{ activeTab === 'map' ? 'visible' : 'collapsed' }}">
 </MapView>

and then instead of just setting the following component properties and let angular do the binding:

this.longitude = Number(args.position.longitude.toFixed(4));
this.latitude = Number(args.position.latitude.toFixed(4));
this.zoomLvl = 12;

I added:

this.mapView.longitude = this.longitude;
this.mapView.latitude = this.latitude;
this.mapView.zoom = this.zoomLvl;

Thanks for taking to time to help try figuring it out @lin-brian-l

0reactions
lin-brian-lcommented, Mar 28, 2018

Can you post your code in your map.ts file?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android GoogleMaps: Zoom in / out animation not working
It will move automatically and then slow down. But zoom in/out animation is not working at all. Tried to set these parameters to...
Read more >
Camera and view | Maps SDK for Android - Google Developers
At any zoom level, you can pan the map, or change its perspective with very little latency thanks to the smaller footprint of...
Read more >
How to keep graphics not moving when map zoom or pan
2. Once the user stops panning the map, you would want to use the screen location of your pushpin and convert that to...
Read more >
Today I learned a handy trick to zoom in and out of Google Maps
Google Maps has a nifty little shortcut that lets you adjust zoom with just one finger. Just double-tap the maps interface, and then...
Read more >
Accessibility in Google Maps - Android
Change display size: To make items on your screen larger, tap Display size, and then set your preferred icon size. Zoom in the...
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