Geolocation and php and database

winter

New Member
I want to use geolocation in my phpwebsite. So what have I done. Users can add information like name, STREET, HOUSENUMBER, ... to a database. This information is clearly stored in the database. If people look for a place with the searchfunction they receive a list of places they searched for. On every founded place at the list, users can click on en they receive a more detailed page about a specific place(record). In this page there has to be geolocation. I already used google and I discovered i need to convert the adress to a lattidude/longitude. This lattitude and longitude must be added to the database but i don't know at what moment (already in the add function, after in a seperate function) and how am i going to do this. At this moment i have a function that calculate the longitude and latitude. I stored them into 2 variables, in javascript but now i'm stuck.Here you see the code i already have.\[code\]<script>$(document).ready(function () { // wire up button click $('#go').click(function () { // get the address the user entered var straat = $('#straat').val(); var nummer = $('#nummer').val(); var address = straat + " " + nummer; alert(address); if (address) { // use Google Maps API to geocode the address // set up the Geocoder object var geocoder = new google.maps.Geocoder(); // return the coordinates geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0]) { // print results printLatLong(results[0].geometry.location.lat(), results[0].geometry.location.lng()); } else { error('Google did not return any results.'); } } else { error("Reverse Geocoding failed due to: " + status); } }); } else { error('Please enter an address'); } }); }); // output lat and longfunction printLatLong(lat, long) { var latitude = lat; var longitude = long; $('.results').text(latitude);} function error(msg) { alert(msg);}</script>\[/code\]
 
Back
Top