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:
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
CitytoAddress. This will permit yous to acquaintance manyAddressrecords to a singleCitytape. It volition also make it uncomplicated to call back all of theAddressrecords that have been entered for whateverCity. - The relationship between
AddressandMetropolissays that for everyAddress, aUrban centermust be. This means that when a user enters anAddress, yous must take the following actions: 1 - Check to come across if theCityfor theAccostalready exists in the database. two - If theCitydoes exist, retrieve itsIDand use that as the foreign fundamentalCity-IDvalue when storing the newAccost. 3 - If theCitydoes non exist, a new uniqueIDmust be created for theCityand theCitymust exist stored in the database. Then theIDfor theMetropolismay be used equally the foreign keyUrban center-IDvalue when storing theAccost. Making sure that everyAddresshas an associatedCityanswers 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"Adresstape, y'all made sure a "MyCity" record exists in theCitytabular array. Retrieving theIDfor theCityis straightforward if another user enters the sameCityor anAccostassociated with the sameMetropolisis entered by a user in the future. - The relationship betwixt
CityandAddresssays that for anyCitythere may be zippo or more associatedAccostrecords. This ensures that the user in your description that searches for just aCitymay shop theUrban centereven if no follow-upAddresssearches have place. TheMetropolisis stored, it has anID, and it is just waiting for whatever newAddressrecords 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