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

  • SEARCH
  • Home
  • 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 6794783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:15:49+00:00 2026-05-26T18:15:49+00:00

I would like to have an input field on my website with autocomplete for

  • 0

I would like to have an input field on my website with autocomplete for places within a certain country. For example in the code below I want to get only places within the country ‘The Netherlands’ as suggestions in the autocomplete.

In the code below I’m getting suggestions for places in all countries, not specified for a certain country.

<!DOCTYPE html>
<html>

  <head>
<title>Google Maps JavaScript API v3 Example: Places Autocomplete</title>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"
  type="text/javascript"></script>

<style type="text/css">
  body {
    font-family: sans-serif;
    font-size: 14px;
  }
  #map_canvas {
    height: 400px;
    width: 600px;
    margin-top: 0.6em;
  }
</style>

<script type="text/javascript">
  function initialize() {

    var input = document.getElementById('searchTextField');
    var autocomplete = new google.maps.places.Autocomplete(input, {country: 'NL'});

    autocomplete.bindTo('bounds', map);

    var infowindow = new google.maps.InfoWindow();
    var marker = new google.maps.Marker({
      map: map
    });

    google.maps.event.addListener(autocomplete, 'place_changed', function() {
      infowindow.close();
      var place = autocomplete.getPlace();
      if (place.geometry.viewport) {
        map.fitBounds(place.geometry.viewport);
      } else {
        map.setCenter(place.geometry.location);
        map.setZoom(17);  // Why 17? Because it looks good.
      }

    });

    setupClickListener('changetype-all', []);

  }
  google.maps.event.addDomListener(window, 'load', initialize);
</script>

</head>
<body>
<div>
  <input id="searchTextField" type="text" size="50">
  <label for="changetype-all"></label>
</div>
</body>
</html>
  • 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-05-26T18:15:50+00:00Added an answer on May 26, 2026 at 6:15 pm

    You can set a bias (which you already have) but without actually checking each autocomplete result with additional code you cannot limit the autocomplete list to a certain country or area, to my knowledge.

    Here is some more information on Google’s Autocomplete: http://code.google.com/apis/maps/documentation/places/autocomplete.html#place_autocomplete_requests

    Ah, if you want to use the geo-autocomplete plugin, then take a look at this example:

    view-source:http://geo-autocomplete.googlecode.com/svn/trunk/demo/ui.demo.html

    This is from their example:

    $('#demo3_location').geo_autocomplete({
        geocoder_region: 'Africa',
        geocoder_types: 'country',
        mapheight: 100, mapwidth: 200, maptype: 'hybrid'
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a text input field containing the $ sign in
I would like to have a zipcode input field that listens when 5 characters
I have an input field which I would like to dynamically validate while user
Assume I have the following input in Pig: some And I would like to
I have byte array as input. I would like to convert that array to
I have some hidden inputs like this <input name=exam.normals[1].blahblah ..../> I would like somehow
I have an input field where a user can paste a link. I would
I have opened a website using WebBrowser. Now I would like to programmatically click
I would like to select the text of the input field which currently has
I have this code that updates a calendar widget and input field, while validating

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.