banner



How To Find The Address Of A House

As far as what the user types into the input box that is associated with the Autocomplete dev-guide, in that location isn't very much y'all can practise to control what they blazon. Notwithstanding, when yous ready the Autocomplete api-doc, you can define options that control the results that will come back. The key for yous will be setting up the types option correctly.

Specific to your question #i, you lot can restrict the results that will come back in the Autocomplete to addresses by setting types to geocode equally 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 #ii, you tin restrict the results that come dorsum in the Autocomplete to cities past setting types to cities as shown here:

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

Also notice that considering the Autocomplete has been restricted to (cities), I have added a componentRestrictions specifier to ready the country inside which to search for cities (in this example, France) and removed the bounds specifier.

Specific to your question #three, 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 clarification in your question, in that location are some central aspects of this blueprint:

  • There is a one-to-many relationship from City to Address. This will permit yous to acquaintance many Address records to a single City tape. It volition also make it uncomplicated to call back all of the Address records that have been entered for whatever City.
  • The relationship between Address and Metropolis says that for every Address, a Urban center must be. This means that when a user enters an Address, yous must take the following actions: 1 - Check to come across if the City for the Accost already exists in the database. two - If the City does exist, retrieve its ID and use that as the foreign fundamental City-ID value when storing the new Accost. 3 - If the City does non exist, a new unique ID must be created for the City and the City must exist stored in the database. Then the ID for the Metropolis may be used equally the foreign key Urban center-ID value when storing the Accost. Making sure that every Address has an associated City answers 1 of the questions yous ask as part of your question #3: How can I observe the effect of the get-go user: "MyCity, MyStreet 12" using "MyCity" key? Considering when y'all stored the "MyCity, MyStreet 12" Adress tape, y'all made sure a "MyCity" record exists in the City tabular array. Retrieving the ID for the City is straightforward if another user enters the same City or an Accost associated with the same Metropolis is entered by a user in the future.
  • The relationship betwixt City and Address says that for any City there may be zippo or more associated Accost records. This ensures that the user in your description that searches for just a City may shop the Urban center even if no follow-up Address searches have place. The Metropolis is stored, it has an ID, and it is just waiting for whatever new Address records that may exist added subsequently.

Finally, you asked one more question as part of question #3: how can I check if the fully accost belong to the city using the ids but? Being able to answer this question is why at that place is a foreign key City-ID that is part of every Address tape. Information technology clearly defines the City that is associated with any Address. Then if y'all have the ID for a Urban center and the ID for an Address, the simplest way to decide if they are a match is: 1 - Retrieve the Address from the database using the Address ID. two - Compare the Urban center-ID value that is part of the Address that was but retrieved from the database with the ID for the City you started with; if they match, yous know the Address is associated with the City and if they don't match, you can be sure at that place is no relationship betwixt 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 yous describe in your question. I included a great deal of item then that all of your points are addressed and in the hope that it volition make my description clear and easy to understand. I hope this helps you lot -

Source: https://stackoverflow.com/questions/10463286/google-places-api-find-an-address-using-the-city

Posted by: joinernessiogs.blogspot.com

0 Response to "How To Find The Address Of A House"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel