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

Getting blank map when no markers defined #481

Open
genlighten opened this issue May 14, 2015 · 1 comment
Open

Getting blank map when no markers defined #481

genlighten opened this issue May 14, 2015 · 1 comment

Comments

@genlighten
Copy link

I use gmaps on our site to display where our service providers are located in a given city, state or country. Sometimes users will search for an area where we don't have any service providers yet. In that case, I still want to display a properly-zoomed map of the respective location. When I have no markers to pass to handler.bounds.extendWith(markers), how can I set the lat/lon centroid and zoom level so I don't get a blank map?

@apneadiving
Copy link
Owner

look at the js code in this plnkr: http://plnkr.co/edit/VvAUnf2uMv38EpjXiBl7?p=preview

  if (_.isEmpty(markers)){
    handler.getMap().setZoom(12);
    handler.getMap().setCenter({lat: -34, lng: 151});
  }
  else{
    handler.bounds.extendWith(markers);
    handler.fitMapToBounds();        
  }

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

2 participants