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 7969955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:19:15+00:00 2026-06-04T07:19:15+00:00

I am planning to use Google Places API in order to create an address

  • 0

I am planning to use Google Places API in order to create an address autocomplete in my web site. My question is about whether my requirements are possible using Google Places.

I have a “Post Request” page where the user posts an address (city, street and house number). I also have a “Search” page where the user can search posts according to the city. Here the user only inserts a city name, without a street and house number.

My questions:

  1. Can I force the user to insert a city, street and house number (inserts of only city or only city and street for example will alert invalid input, or the autocomplete will return only results of city, street and house number)?

  2. Can I force the user insert city only (without street and house number)?

  3. Assuming the user posts an address with “MyCity, MyStreet 12”. In the background of the application I get an id of this specific location and store it. Another user is searching for posts and inserts “MyCity”. In the background I get the specific id of “MyCity” and use this id in order to search in my db. How can I find the result of the first user: “MyCity, MyStreet 12” using “MyCity” key?
    In other words, assume I have a location id that represents a city and other location id that represents fully address (city, street, house number), how can I check if the fully address belong to the city using the ids only?

  • 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-04T07:19:16+00:00Added an answer on June 4, 2026 at 7:19 am

    As far as what the user types into the input box that is associated with the Autocompletedev-guide, there isn’t very much you can do to control what they type. However, when you set up the Autocompleteapi-doc, you can define options that control the results that will come back. The key for you will be setting up the types option correctly.

    Specific to your question #1, you can restrict the results that will come back in the Autocomplete to addresses by setting types to geocode as shown in this example:

    var defaultBounds = new google.maps.LatLngBounds(
      new google.maps.LatLng(-33.8902, 151.1759),
      new google.maps.LatLng(-33.8474, 151.2631));
    
    var input = document.getElementById('searchTextField');
    var options = {
      bounds: defaultBounds,
      types: ['geocode']
    };
    
    autocomplete = new google.maps.places.Autocomplete(input, options);
    

    Specific to your question #2, you can restrict the results that come back in the Autocomplete to cities by setting types to cities as shown here:

    var input = document.getElementById('searchTextField');
    var options = {
      types: ['(cities)'],
      componentRestrictions: {country: 'fr'}
    };
    
    autocomplete = new google.maps.places.Autocomplete(input, options);
    

    Also notice that because the Autocomplete has been restricted to (cities), I have added a componentRestrictions specifier to set the country within which to search for cities (in this case, France) and removed the bounds specifier.

    Specific to your question #3, you can create two tables, one to store City data, the other to store Address data, as shown in the following UML diagram:

    enter image description here

    Based on the description in your question, there are some key aspects of this design:

    • There is a one-to-many relationship from City to Address. This will allow you to associate many Address records to a single City record. It will also make it simple to retrieve all of the Address records that have been entered for any City.
    • The relationship between Address and City says that for every Address, a City must exist. This means that when a user enters an Address, you must take the following actions: 1 – Check to see if the City for the Address already exists in the database. 2 – If the City does exist, retrieve its ID and use that as the foreign key City-ID value when storing the new Address. 3 – If the City does not exist, a new unique ID must be created for the City and the City must be stored in the database. Then the ID for the City may be used as the foreign key City-ID value when storing the Address. Making sure that every Address has an associated City answers one of the questions you ask as part of your question #3: How can I find the result of the first user: “MyCity, MyStreet 12” using “MyCity” key? Because when you stored the “MyCity, MyStreet 12” Adress record, you made sure a “MyCity” record exists in the City table. Retrieving the ID for the City is straightforward if another user enters the same City or an Address associated with the same City is entered by a user in the future.
    • The relationship between City and Address says that for any City there may be zero or more associated Address records. This ensures that the user in your description that searches for just a City may store the City even if no follow-up Address searches take place. The City is stored, it has an ID, and it is just waiting for any new Address records that may be added later.

    Finally, you asked one more question as part of question #3: how can I check if the fully address belong to the city using the ids only? Being able to answer this question is why there is a foreign key City-ID that is part of every Address record. It clearly defines the City that is associated with any Address. So if you have the ID for a City and the ID for an Address, the simplest way to determine if they are a match is: 1 – Retrieve the Address from the database using the Address ID. 2 – Compare the City-ID value that is part of the Address that was just retrieved from the database with the ID for the City you started with; if they match, you know the Address is associated with the City and if they don’t match, you can be sure there is no relationship between that Address and that City.

    I’m not entirely sure what you are trying to achieve with the addresses and the cities, but I’ve tried to give you a solid solution that covers the things you describe in your question. I included a great deal of detail so that all of your points are addressed and in the hope that it will make my description clear and easy to understand. I hope this helps you –

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning to use Google web fonts on my site. My site has lots
I am planning to use Wurfl in a web application in order to distinguish
I am planning to build a web application highly based on Google Maps API.
Let me share my findings before asking the question. Google Places API documentation says:
I was planning to use db4o for a website. It's a microblog site with
I am planning to use Google charts to display the data available on my
I'm planning to try out Google's NaCL. Which IDE should i use for developing?
Hello i'm planning to create an application on google app engine, the application will
I'm in the early planning phase for a project and determining whether to use
We're planning to use Google Analytics to track ad click-through referrals, through the Android

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.