Hi, my first post, go easy on me please:).
I’ll be upfront - i’m a novice at php, little behind on the tech. However, i am learning and maybe with your help i might learn something new Ok so i’ll lay it out to be clear and not lead to misunderstanding.
My problem is this:
I am trying to add to my signup form (users sign up to post listings of their music) GeoLocation. I have added the code to show markers, input manually coordiates etrc. The problem is that once the form is submitted, it does not save the users selected marker on the map.
My sign up uses mysql and Post to pass and storer user data, it is then posted on my listings page.
Here is the code i’m using:
(new post.php)
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div id="map" style="width: 500x; height: 500px"></div>
<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 J.S)
var mapInstance;
var marker;
function placeMarker(location) {
if (marker) {
marker.setPosition(location);
} else {
marker = new google.maps.Marker({
position: location,
map: mapInstance
});
}
}
function submitAction() {
alert("Value of firstname is " + $("#firstnamefield").val());
alert("Value of lastname is " + $("#lastnamefield").val());
alert("Value of latlng is " + $("#latlngfield").val());
}
$(document).ready(function() {
var latlng = new google.maps.LatLng(35.603789, -77.364693);
var mapOptions = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DEFAULT
}
};
mapInstance = new google.maps.Map(document.getElementById("map"), mapOptions);
google.maps.event.addListener(mapInstance, 'click', function(event) {
placeMarker(event.latLng);
});
$("#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();
});
});
Now i apologise if this question does not reflect the nature of this section of the site, that it might also be best to have posted on Google support maybe?. Regardless, thank you for reading, time and support.
P.S I can provide my listing code or if you wish to save your time then please just link me or advise me where to find the information i require.
Thank you