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
City
toAddress
. This will permit yous to acquaintance manyAddress
records to a singleCity
tape. It volition also make it uncomplicated to call back all of theAddress
records that have been entered for whateverCity
. - The relationship between
Address
andMetropolis
says that for everyAddress
, aUrban center
must be. This means that when a user enters anAddress
, yous must take the following actions: 1 - Check to come across if theCity
for theAccost
already exists in the database. two - If theCity
does exist, retrieve itsID
and use that as the foreign fundamentalCity-ID
value when storing the newAccost
. 3 - If theCity
does non exist, a new uniqueID
must be created for theCity
and theCity
must exist stored in the database. Then theID
for theMetropolis
may be used equally the foreign keyUrban center-ID
value when storing theAccost
. Making sure that everyAddress
has an associatedCity
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 theCity
tabular array. Retrieving theID
for theCity
is straightforward if another user enters the sameCity
or anAccost
associated with the sameMetropolis
is entered by a user in the future. - The relationship betwixt
City
andAddress
says that for anyCity
there may be zippo or more associatedAccost
records. This ensures that the user in your description that searches for just aCity
may shop theUrban center
even if no follow-upAddress
searches have place. TheMetropolis
is stored, it has anID
, and it is just waiting for whatever newAddress
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