1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Geocoding right informations and posting them to inputs.

Discussion in 'JavaScript' started by sooly, Dec 17, 2012.

  1. #1
    I have already made progress in my map, but now i got confused. Im having this : jsfiddle.net/HyKeA/ where im trying to get informations like Address , City , State and save them to my MysQL database..
    So what do i want. In my Address input i want to get postal number and street name.. like.. Goodstreet 400 56.
    In my City i want to have city.. like .. German city
    And in State i want to have state.. like .. Germany
    Thats all. Thanks everyone.

    Code (Text):
    1.  
    2.  
    3.   function reverseGeocodeResult(results, status) {
    4.     currentReverseGeocodeResponse = results;
    5.     if(status == 'OK') {
    6.       if(results.length == 0) {
    7.         document.getElementById('formatedAddress').value = 'None';
    8.       } else {
    9.               var components = results[0].address_components;
    10.               var parsed_components = {};
    11.               for (var i = 0, l = components.length; i < l; i++) {
    12.                   for (var ii = 0, ll = components[i].types.length; ii < ll; ii++) {
    13.                       parsed_components[components[i].types[ii]] = components[i].long_name;
    14.                   }
    15.               }
    16.           var address = {};
    17.           address.address = parsed_components.route;
    18.           if (parsed_components.street_number !== undefined) {
    19.               address.address += ' ' + parsed_components.street_number;
    20.           }
    21.           address.city = parsed_components.administrative_area_level_2;
    22.           address.state = parsed_components.administrative_area_level_1;
    23.              
    24.           document.getElementById('formatedAddress').value = address.address + ', City: ' + address.city + ', State: ' + address.state;
    25.           document.getElementById('stat').value = 'State: ' + address.state;
    26.           document.getElementById('mesto').value ='City: ' + address.city;
    27.           console && console.log(parsed_components, address);
    28.       }
    29.     } else {
    30.       document.getElementById('formatedAddress').value = 'Error';
    31.     }
    32.   }
    33.  

    to


    Code (Text):
    1.  
    2. <label>Address :</label> <input id="formatedAddress" size="50" type="text" name="adresa" ><br>
    3. <label>state :</label> <input id="stat" size="50" type="text" name="adresa" ><br>
    4. <label>city :</label> <input id="mesto" size="50" type="text" name="adresa" ><br>
    5. <label>Lat : </label><input id="lat" size="50" type="text" name="lat" >       <br>
    6. <label>Lng : </label><input id="lng" size="50" type="text" name="lng" >      <br>
    7.  
    8.  
     
    Last edited: Dec 17, 2012
    sooly, Dec 17, 2012 IP