Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7652565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:48:13+00:00 2026-05-31T11:48:13+00:00

i’m busy with a school project and I have to build a web app.

  • 0

i’m busy with a school project and I have to build a web app. One function that I want to use is Google Maps and HTML5 Geo Location to pin point what the location of the mobile user is.

I have found this HTML5 Geo Location function on http://merged.ca/iphone/html5-geolocation and works very well for me. However, I want the adress data to be placed into a form so that I can submit it to my database when a mobile user Geo locates his position. This causes the marker to be saved and can be viewed on a global website.

Who know how to get the “Your address:” data loaded into a input field of a form?
Below you can find my Html file. Maybe somebody got a better suggestion perhaps?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<title>HTML 5 Geolocation</title>

<style>
#map {
    height:300px;
    width:300px;
}

</style>    
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1"); google.load("jqueryui", "1");</script>

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAiUzO1s6QWHuyzxx-JVN7ABSUL8-Cfeleqd6F6deqY-Cw1iTxhxQkovZkaxsxgKCdn1OCYaq7Ubz3SQ" type="text/javascript"></script>
<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=n2wY9mzV34Hsdslq6TJoeoJDLmAfzeBamSwJX7jBGLnjM7oDX7fU.Oe91KwUbOwqzvc-"></script>
<script type="text/javascript">

// Geolocation with HTML 5 and Google Maps API based on example from maxheapsize: http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/
//
// This script is by Merge Database and Design, http://merged.ca/ -- if you use some, all, or any of this code, please offer a return link.

var map;
var mapCenter
var geocoder;
var fakeLatitude;
var fakeLongitude;

function initialize() 
{   

    if (navigator.geolocation) 
    {
        navigator.geolocation.getCurrentPosition( function (position) {  

            // Did we get the position correctly?
            // alert (position.coords.latitude);

            // To see everything available in the position.coords array:
            // for (key in position.coords) {alert(key)}

            mapServiceProvider(position.coords.latitude,position.coords.longitude);

        }, // next function is the error callback
            function (error)
            {
                switch(error.code) 
                {
                    case error.TIMEOUT:
                        alert ('Timeout');
                        break;
                    case error.POSITION_UNAVAILABLE:
                        alert ('Position unavailable');
                        break;
                    case error.PERMISSION_DENIED:
                        alert ('Permission denied');
                        break;
                    case error.UNKNOWN_ERROR:
                        alert ('Unknown error');
                        break;
                }
            }
        );
    } 
    else 
    {
      alert("I'm sorry, but geolocation services are not supported by your browser or you do not have a GPS device in your computer. I will use a sample location to produce the map instead.");

      fakeLatitude = 49.273677;
      fakeLongitude = -123.114420;

      //alert(fakeLatitude+', '+fakeLongitude);   
      mapServiceProvider(fakeLatitude,fakeLongitude);
    }  
}

function mapServiceProvider(latitude,longitude)
{
    if (window.location.querystring['serviceProvider']=='Yahoo')
    {
        mapThisYahoo(latitude,longitude);
    }
    else
    {
        mapThisGoogle(latitude,longitude);
    }
}

function mapThisYahoo(latitude,longitude)
{
    var map = new YMap(document.getElementById('map'));  
    map.addTypeControl();   
    map.setMapType(YAHOO_MAP_REG);  
    map.drawZoomAndCenter(latitude+','+longitude, 3);

    // add marker
    var currentGeoPoint = new YGeoPoint( latitude, longitude );  
    map.addMarker(currentGeoPoint);

    // Start up a new reverse geocoder for addresses?
    // YAHOO Ajax/JS/Rest API does not yet support reverse geocoding (though they do support it via Actionscript... lame)
    // So we'll have to use Google for the reverse geocoding anyway, though I've left this part of the script just in case Yahoo! does support it and I'm not aware of it yet
    geocoder = new GClientGeocoder();
    geocoder.getLocations(latitude+','+longitude, addAddressToMap);
}

function mapThisGoogle(latitude,longitude)
{
    var mapCenter = new GLatLng(latitude,longitude);
    map = new GMap2(document.getElementById("map"));
    map.setCenter(mapCenter, 15);
    map.addOverlay(new GMarker(mapCenter));

    // Start up a new reverse geocoder for addresses?
    geocoder = new GClientGeocoder();
    geocoder.getLocations(latitude+','+longitude, addAddressToMap);
}

function addAddressToMap(response)
{
    if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
    } else {
        place = response.Placemark[0];
        $('#address').html('Your address: '+place.address);
    }
}

window.location.querystring = (function() {

    // by Chris O'Brien, prettycode.org
    var collection = {};
    var querystring = window.location.search;
    if (!querystring) {
        return { toString: function() { return ""; } };
    }
    querystring = decodeURI(querystring.substring(1));

    var pairs = querystring.split("&");

    for (var i = 0; i < pairs.length; i++) {

        if (!pairs[i]) {
            continue;
        }
        var seperatorPosition = pairs[i].indexOf("=");

        if (seperatorPosition == -1) {
            collection[pairs[i]] = "";
        }
        else {
            collection[pairs[i].substring(0, seperatorPosition)] 
                = pairs[i].substr(seperatorPosition + 1);
        }
    }

    collection.toString = function() {
        return "?" + querystring;
    };

    return collection;
})();
</script>

</head>
<body onLoad="initialize()">
<div id="content">
<div id="map"></div>
<p id="address"></p>

<form id="ContactForm" action="">
                            <p>
                                <label>Topic</label>
                                    <input id="event" name="event" maxlength="120" type="text" autocomplete="off"/>
                            </p>
                            <p>
                                <label>Address</label>
                                    <input id="address" name="address" maxlength="120" type="text" autocomplete="off"/>
                            </p>
                            <input id="send" type="button" value="Send"/>
                            <input id="newcontact" name="newcontact" type="hidden" value="1"></input>
                        </form>
</div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:48:14+00:00Added an answer on May 31, 2026 at 11:48 am

    You have to use JavaScript to set the value of address input field, this way

    1- Add name attribute to the form and input.

    2- document.formName.inputName.value=place.address;

    Good Luck

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.