I am writing something that can take a person-put address and converts it to some geolocation for GoogleMaps' api.

Edit: I actually do wish to submit the shape data, though.. I believe. I am unsure if posting the shape is essential, however the finish result is it should produce a publish in wordpress that contains the title, address, and geo values.

The technique known as through the submit button works properly when the <form></form> tags are removed. When the <form> tags remain the shape, the technique it's still known as however it will not geocode anything. Did I setup my form improperly?

This is actually the form:

$title = $_POST['title'];
$address = $_POST['address'];

$new_post = array(
     'post_title' => $title,
     'post_content' => 'This is my post.',
     'post_status' => 'publish',
     'post_type' => 'post',
     'address' => $address,
     'geo' => $geo,

$post_id = wp_insert_post($new_post);

update_post_meta($post_id, 'address', $address, true);
update_post_meta($post_id, 'geo', $geo, true);  


<?php get_header()?>

    <label>Event: </label><input id="title"  type="text"/>
    <label>Address: </label><input id="address"  type="text"/>
    <div id="map_canvas" style="width:500px; height:500px"></div><br/>
    <label>latitude: </label><input id="latitude" type="text"/><br/>
    <label>longitude: </label><input id="longitude" type="text"/><br/>
    <input type="submit" id="compute" onClick="getCoordinates()" value="lets try it">

    <input type="hidden" name="action" value="new_post" />
    <?php wp_nonce_field( 'new-post' ); ?>

<?php get_footer()?>

This is actually the relevant function:

function getCoordinates() {
//variables are set up on page initialization   
    geocoder.geocode( { 'address': $('#address').val() }, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        alert ('latitude: ' + results[0].geometry.location.lat() + ' longitude: ' + results[0].geometry.location.lng());
        $('#latitude').val( results[0].geometry.location.lat() ) ;
        $('#longitude').val( results[0].geometry.location.lng() ) ;
        $geo =  results[0].geometry.location.lat() + "," + results[0].geometry.location.lng();
        var marker = new google.maps.Marker({
        map: map,
        position: results[0].geometry.location


Alter the input button from type="submit" to type="button" and then leave the shape tags off. You simply make use of a form having a submit button inside when you wish to really submit the shape, not execute a javascript only action.

Once the elements are used, it's wise to bind this geocode function towards the onsubmit event for your .

<form onsubmit="getCoords()">
function getCoords(){

  alert("this is the request callback");

//Always return false in the onsubmit event if you want to stop the browser from trying to POST anything
return false;