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 7803343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:33:06+00:00 2026-06-02T01:33:06+00:00

I have an html form and I want to embed google map so the

  • 0

I have an html form and I want to embed google map so the user can pin point some location. After submitting the form how do I get the location?

Thanks

  • 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-06-02T01:33:07+00:00Added an answer on June 2, 2026 at 1:33 am

    Although @zerkms gave a pointer to the correct information, that might not be enough. I’ve created a fiddle with a working example: to help. The basic parts are:

    1. A javaScript function that uses the maps API to put down a marker where the user clicks (this is placeMarker)
    2. A javaScript click handler for the submit button that prevents the normal form submit and records the current latlng of the marker in a hidden form field
    3. An invocation of the normal form submit

    Here is the placeMarker code:

    function placeMarker(location) {
        if (marker) {
            marker.setPosition(location);
        } else {
            marker = new google.maps.Marker({
                position: location,
                map: mapInstance
            });
        }
    }
    

    And here is the jQuery code used for handling the submit:

    $("#submitbutton").on("click", function(e) {
        // Prevent normal submit action
        e.preventDefault();
        // Collect current latlng of marker and put in hidden form field
        if (marker) {
            $("#latlngfield").val(marker.getPosition().toString());
        } else {
            $("#latlngfield").val("not entered");
        }
        // Show results for debugging
        submitAction();
        // Uncomment this for production and remove submitAction() call
        // $("#dataform").submit();
    });
    

    Here’s the form I used:

    <form id="dataform">
        <fieldset>
            <legend>Form Information</legend>    
                <label for="firstnamefield">First Name</label>
                <input type="text" name="firstname" id="firstnamefield"><br>
                <label for="lastnamefield">Last Name</label>
                <input type="text" name="lastname" id="lastnamefield"><br>
                <input type="reset" name="reset" value="Clear">
                <input type="submit" name="submit" id="submitbutton" value="Submit Data">
                <input type="hidden" name="latlng" id="latlngfield">
        </fieldset>
    </form>
    

    The submitAction is not needed in production, I just wanted to show what happens with the values:

    function submitAction() {
        alert("Value of firstname is " + $("#firstnamefield").val());
        alert("Value of lastname is " + $("#lastnamefield").val());
        alert("Value of latlng is " + $("#latlngfield").val());
    }
    

    Hope this helps!

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

Sidebar

Related Questions

I have an HTML form where the user can type in any number:5, 8,
I have a html form. I want the user to be able to mark
I have an HTML form containing some textboxes and two jqGrids. The user selects
I have an HTML form where I want to add some validation logic. In
I have an HTML form that lets the user write what they want to
I have a Html form. I want to get the file containing posted form's
I have a html form with no submit button. I want to submit that
Suppose you're building an HTML form and you want to have 2 or more
I have an HTML form with three inputs for phone number input. I want
I have an HTML form consisting of some text-inputs. I'm using jqTransform to prettify

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.