troubleshooting Question

Setting a Central Location in Google Maps

Avatar of APD Toronto
APD TorontoFlag for Canada asked on
JavaScriptGoogle
2 Comments1 Solution23 ViewsLast Modified:
Hi Experts,

I am just starting out with Google Maps API, and every example that I see starts off with a static central location, like Toronto that I have below.

My question is, do I really need a central location, because I dont know where that center will be. Toronto is in Ontario, but the user may want to see stores in BC. I am still working towards preparing the longitude/latitude, but I just thinking about my next step.

function get_map(){

    var toronto = {lat: 43.6560531, lng: -79.3869317};
    map = new google.maps.Map(document.getElementById('results_map'), {
      zoom: 12,
      center: toronto
    });
    
    geocoder = new google.maps.Geocoder();
  
}

Thank you
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros