Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member hagen's Avatar
    Join Date
    Aug 2005
    Posts
    408
    Member #
    10882
    Liked
    1 times
    Hi All, I have cobbled together the following code...

    It does some global setting up for google map,and generates an alert with the point which is a loingitude and lattitude position....

    Now I want to generate the point in a text field in my html code...

    In other languages it would be simple I would just use a global varable...

    Any ideas?

    Help :-) Many thanks -Hagen



    <script src=\"http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=$map_key\"
    type=\"text/javascript\"></script>
    <script type=\"text/javascript\">


    var map;
    var geocoder;

    function initialize() {
    var address = '$address';
    map = new GMap2(document.getElementById(\"map_canvas\"));


    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());

    geocoder = new GClientGeocoder();
    showLocation();
    }



    // addAddressToMap() is called when the geocoder returns an
    // answer. It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
    map.clearOverlays();
    if (!response || response.Status.code != 200) {
    alert(\"Sorry, we were unable to geocode that address\");
    } else {
    place = response.Placemark[0];
    point = new GLatLng(place.Point.coordinates[1],
    place.Point.coordinates[0]);
    marker = new GMarker(point);
    map.setCenter(point,13);
    map.addOverlay(marker);
    alert(\"Point: \" + point);
    }
    }

    // showLocation() is called when you click on the Search button
    // in the form. It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation() {
    var address = '$address';
    geocoder.getLocations(address, addAddressToMap); /// X
    }


    </script>
    Hagen Rose: hagen(at)jxwd(dot)co(dot)uk
    JX Web Development, Bournemouth, Dorset...JXWD.co.uk

  2.  

  3. #2
    Senior Member
    Join Date
    Dec 2009
    Location
    Chicago, IL
    Posts
    114
    Member #
    20579
    Liked
    2 times
    Maybe I'm just not understanding what you're trying to do. Are you trying to write your latlng into a text field? If so, that's fairly easy. You can just get the element by id, and output the point variable value into the field.

    Am I understanding this right?

  4. #3
    Senior Member hagen's Avatar
    Join Date
    Aug 2005
    Posts
    408
    Member #
    10882
    Liked
    1 times
    Yes that was the solution... sorry don't really know much about the JAVA environment...

    I replaced the alert with:

    document.back_button.back_data.value = point;


    Then added this to the page:

    <form name=back_button class=back_button method=post>
    <input name=back_data type=hidden />
    </form>

    Then when the back button was pressed the calculated position was saved to the database for subsiquent searches.... IE harvesting google's data in a friendly way...

    -Hagen
    Hagen Rose: hagen(at)jxwd(dot)co(dot)uk
    JX Web Development, Bournemouth, Dorset...JXWD.co.uk


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:25 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com