Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map.setCenter doesn't do anything #287

Open
t-zander opened this issue Dec 3, 2018 · 3 comments
Open

map.setCenter doesn't do anything #287

t-zander opened this issue Dec 3, 2018 · 3 comments

Comments

@t-zander
Copy link

t-zander commented Dec 3, 2018

IMPORTANT
Please be specific with an example. An issue with no example or unclear requirements may be closed.

Steps to reproduce and a minimal demo
Just try to perform this.map.setCenter({lat : anyNumber Here, lng: anyNumberHere})
as well as this.map.setZoom()
It doesn't give any errors but it also doesn't work.
Am I doing something wrong?
What is the proper way to center my map programatically then?

  • What steps should we try in your demo to see the problem?
  • Plunker example
  • If you cannot reproduce an issue with a plunker example, it's your environmental issue

Current behavior

  • Doesn't center the map doesn't change zoom lvl

Expected/desired behavior

  • Ability to zoom in out the map, to center it

Other information

@allenhwkim
Copy link
Contributor

Please provide example that does not work.

@sinani
Copy link

sinani commented Jan 25, 2019

Case 1

@Component({ ... })
export class MyMapComponent {
  center = { lat: 1; lng: 2 };

  onClick() {
    this.center = { lat: 45, lng, 45 };
  }
<pre>{{center|json}}</pre>
<ngui-map #nguimap [center]="center"></ngui-map>

Case 2
Could we have a setCenter(position) or panTo(position) method?

setCenter(): void {

@sinani
Copy link

sinani commented Jan 25, 2019

This worked for me:

onMapReady($event) {
  this.mapObject = $event.data.map;
}

onCenterClick() {
  this.mapObject.setCenter({ // or .panTo(..)
    lat: 43.7260366,
    lng: -79.829754
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants