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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:54:32+00:00 2026-06-12T20:54:32+00:00

I am creating a website for a magazine which has a page devoted to

  • 0

I am creating a website for a magazine which has a page devoted to events (such as County Shows etc.) This page has an interactive map at the top (built with google maps), and then a section with the different events and their details in a 3col grid.

My boss wanted to have it so that when the website owners (we’ll refer to them as the editor) are adding the event, it is possible for them to add the address of the event. When the editor saves the event, it then geocodes the address, and saves the lat&lng into their own hidden input fields.

There is then a loop on the Events page within the Google Maps syntax to create markers for each event using their LatLng.

I have the page created with the map but I do not know how to go about geocoding the address in the back end.

I do not mind whether or not the geocoding is done automatically when saving the post, or if it is manually converted through clicking a button. I just need a way to save the LatLng so I can call it from the loop.

So how can I do this? I understand I’m going to need some jQuery for the AJAX request, but which file should this go in? (the geocode.php

Code time!

Geocode.php:

$result = json_decode(file_get_contents($geoCodeURL), true); 

echo $result['results'][0]['geometry']['location']['lat'];
echo ',';
echo $result['results'][0]['geometry']['location']['lng'];

Yeah… That’s all I got.

Snippet of Functions.php

    <td>
        <form class="geocode" action="<?php bloginfo('template_url');?>/geocode.php" method="post">
        <input type="text" name="addr" />
        <input type="submit" value="" />
        </form>
        <input type="text" value="" name="eventLatLng" class="latlng" />
    </td>

P.S. I’m very sorry if this is unclear, I’ve never worked with AJAX and I’m a bit confused as to how to explain it, so sorry if I wasn’t much help.

  • 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-12T20:54:33+00:00Added an answer on June 12, 2026 at 8:54 pm

    Here is the code for enter the address by google map and get their lat & long.

     <!--code for google address api-->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <input name="add" type="text" id="address" class="required" style="width: 500px;" onblur="cordinate()">
                <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places&language=en-AU"></script>
                <script>
                    var autocomplete = new google.maps.places.Autocomplete($("#address")[0], {});
    
                    google.maps.event.addListener(autocomplete, 'place_changed', function() {
                    var place = autocomplete.getPlace();
                    console.log(place.address_components);
                    });
                </script>
                <!--code for google address api-->
    
    
    
                <!--code for google address cordinates By Harshal-->
    
                <script>
    
                function cordinate()
                {
                    geocoder = new google.maps.Geocoder(); // creating a new geocode object
    
                    address1 = document.getElementById("address").value;
    
                        if (geocoder)
                    {
                    geocoder.geocode( { 'address': address1}, function(results, status)
                    {
                    if (status == google.maps.GeocoderStatus.OK)
                    {
                    //location of first address (latitude + longitude)
                    var location1 = results[0].geometry.location;
                    document.getElementById("cor").value = location1;
    
                    //alert(location1);
                    } else
                    {
                    alert("Geocode was not successful for the following reason: " + status);
                    }
                    });
    
                    }//end of If
    
                }
                </script>
                <!--code for google address cordinates-->
                <input type="hidden" name="cor" id="cor">//in this input field you will get the cordinates.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a website page which has to different forms, depending on user input
I am creating a website which has 1 dropdownlist that bound to Northwind database,
When creating a website using Asp.Net and using controls such as the ListView is
I am creating a website. It has a database and I'm trying to work
I am creating a website with four textarea forms. Each form has a word
I'm creating a website which is white, so I dont have any background assigned.
I am creating a website which uses jquery scrolling as the method of navigation
I am creating a website that has 5 different sub-sites each with the same
I am creating a website and on one particular page, am wanting to send
So I'm creating a website that has all of its content in one centered

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.