I'm a noob at C#, this is my first programming language and I am currently working my way through the book C# in a Nutshell. I have started a project to automate a lot of what I do at work all day.
If it is possible can anyone recommend a good place to start researching how to do this specifically? The only resource that I can find is:
Google maps autocomplete textbox in c#
But he says in the end he could never get it to work. It gives me an idea about how to go about it but I don't know what he was doing wrong.
I want to implement an order placing system and the first thing the user will need to do is enter customer name and address.
The end game is getting the address and comparing it to a database of stored addresses, if the post/zip code matches then load up the account and if it doesn't then create a new account using the address details.
Being able to use a Microsoft or Google api would prevent me from having to host a database with every UK address in it.
EDIT: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform
As per Google, below is the JavaScript code for this functionality but in a web page. As you can see the comments state that the JS library Places is required. Does this mean I can't just work on the conversion and that some functionality will be missing. This is all embedded within HTML which I have not included:
// This example displays an address form, using the autocomplete feature
// of the Google Places API to help users fill in the information.
// This example requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js? key=YOUR_API_KEY&libraries=places">
var placeSearch, autocomplete;
var componentForm = {
street_number: 'short_name',
route: 'long_name',
locality: 'long_name',
administrative_area_level_1: 'short_name',
country: 'long_name',
postal_code: 'short_name'
};
function initAutocomplete() {
// Create the autocomplete object, restricting the search to geographical
// location types.
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['geocode']});
// When the user selects an address from the dropdown, populate the address
// fields in the form.
autocomplete.addListener('place_changed', fillInAddress);
}
function fillInAddress() {
// Get the place details from the autocomplete object.
var place = autocomplete.getPlace();
for (var component in componentForm) {
document.getElementById(component).value = '';
document.getElementById(component).disabled = false;
}
// Get each component of the address from the place details
// and fill the corresponding field on the form.
for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
if (componentForm[addressType]) {
var val = place.address_components[i][componentForm[addressType]];
document.getElementById(addressType).value = val;
}
}
}
// Bias the autocomplete object to the user's geographical location,
// as supplied by the browser's 'navigator.geolocation' object.
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var circle = new google.maps.Circle({
center: geolocation,
radius: position.coords.accuracy
});
autocomplete.setBounds(circle.getBounds());
});
}
}