Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:16:19+00:00 2026-06-07T01:16:19+00:00

so.. i run into a possibly very common problem. just started implementing google maps

  • 0

so..
i run into a possibly very common problem.

just started implementing google maps api, and following is my code to resolve a city into lat/lang and center the map there:

function SetMapAddress(address) {  // "London, UK" for example 
  var geocoder = new google.maps.Geocoder();
  if (geocoder) {
     geocoder.geocode({ 'address': address }, function (results, status) {
     if (status == google.maps.GeocoderStatus.OK) {
        var loc = results[0].geometry.location;
        document.map.setCenter(new google.maps.LatLng(loc.lat(),loc.lng(), 13));
     }

the problem is that i am passing a static zoom (13).

if someone types a name of a country, i’d like to zoom out more. if it is a city, i’d like to zoom in more etc..

the only thing i can think of is to figure out appropriate zoom for every city and country, store them in some hash, and try to figure out which is being used, to pass appropriate zoom.

maybe google thought of a more intelligent approach ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:16:23+00:00Added an answer on June 7, 2026 at 1:16 am

    The geocoder returns a “recommended” viewport

    Which you can use in your SetMapAddress function like this:

     function SetMapAddress(address) {  // "London, UK" for example 
       var geocoder = new google.maps.Geocoder();
       if (geocoder) {
          geocoder.geocode({ 'address': address }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
              document.map.fitBounds(results[0].geometry.viewport);
            }
          });
       }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just run into another problem with my To-do-like sortable list made with Knockout
I've run into a very odd issue with IE8's JS engine (possibly previous versions
I run into this problem. I have a textarea which I only want to
I run into follow problem. Did I miss anything? Association.all().count() 1 Association.all().fetch(1) [Association(**{'server_url': u'server-url',
I run into the following issue semi-regularly: I make changes to XAML or some
I run into the following errors when i try to store a large file
I run into an interesting problem while was using combos in input form. My
I've run into a known problem, which is when Firefox's default search for some
I have run into a problem with Eclipse Indigo, attempting to start up my
I've run into the following issue which is not difficult to solve by any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.