window.geocoder = new google.maps.Geocoder();

function queryLatLng(adres,postcode,plaats,callback) {
	if (window.geocoder) {
		
		var position = {
			posLat: 0,
			posLng: 0
		};
		window.geocoder.geocode( { 
			'address': adres + ", " + postcode + ", " + plaats
		}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				
				try {
					position.posLat = results[0].geometry.location.lat();
					position.posLng = results[0].geometry.location.lng();
				} catch (e) {
					if (typeof(console) != "undefined") {
						console.log("Failure parsing geocode results. Results below. Status="+status);
						console.log(results);
					}
				}
				
				callback(position);

			} else {
				if (typeof(console) != "undefined") {
					console.log("Could not query location information: " + status);
				}
				callback(position);
			}
		});
	} else {
		alert("Fout met ophalen van kaartlokatie adres.");
	}
}

