Having resisted posting until I trawled through the forums and tried various examples, I have no option but to admit defeat ... grrr.
I'm trying to implement what seems to be a common solution so am really hoping someone can see where I'm going wrong.
Having been using Chronoforms for a few days now and achieved most of the other form requirements both in simple mode and advanced mode, I'm starting to get a good feel for how to use CF (excellent product BTW !!) so a little frustrated that this is defeating me.
I have been looking at the Google Maps JavaScript API v3 reference material and it all seems to make sense so not sure why it's not working for me.
What I'm trying to achieve
[list]Present a google map on a form (done)
User can either enter an address or click on the map and place a marker (problem)
Existing locations from the database displayed on the map (haven't started)[/list]
The problem
I'm trying to get the asynchronous callback to do the address lookup (Geocoding) but am simply not getting any response.
The code I'm using suggests that once the lookup is achieved and the GeocoderStatus is OK the map should centre on the location.
I've taken the code pretty much verbatim from the Google website, so am wondering if the issue I'm having is with making the making and handling the response, or simply my understanding of where to put the code in CF.
My Config
I have created a completely new form just to test the map so nothing from the standard form is interfering
I have a custom code module:
In the OnLoad event block I have:
1) A "Custom code" block to load the Google scripts
2) A "Load Javascript" block
3) The "Render HTML" command block (the only option changed from default is to perform a "POST").
As you can see it's all pretty basic, so convinced I'm doing something dumb, but as it's almost 1am I can't for the life of me see what it is ... HELP !!! 😲
Thanks in advance,
Tim
I'm trying to implement what seems to be a common solution so am really hoping someone can see where I'm going wrong.
Having been using Chronoforms for a few days now and achieved most of the other form requirements both in simple mode and advanced mode, I'm starting to get a good feel for how to use CF (excellent product BTW !!) so a little frustrated that this is defeating me.
I have been looking at the Google Maps JavaScript API v3 reference material and it all seems to make sense so not sure why it's not working for me.
What I'm trying to achieve
[list]Present a google map on a form (done)
User can either enter an address or click on the map and place a marker (problem)
Existing locations from the database displayed on the map (haven't started)[/list]
The problem
I'm trying to get the asynchronous callback to do the address lookup (Geocoding) but am simply not getting any response.
The code I'm using suggests that once the lookup is achieved and the GeocoderStatus is OK the map should centre on the location.
I've taken the code pretty much verbatim from the Google website, so am wondering if the issue I'm having is with making the making and handling the response, or simply my understanding of where to put the code in CF.
My Config
I have created a completely new form just to test the map so nothing from the standard form is interfering
I have a custom code module:
<div id="panel">
<input id="address" type="textbox" value="Worcester, England">
<input type="button" value="Geocode" onclick="codeAddress()">
</div>
<div id="googleMap" style="width:500px;height:380px;"></div>
In the OnLoad event block I have:
1) A "Custom code" block to load the Google scripts
<?php
$doc =& JFactory::getDocument();
$doc->addScript("https://maps.googleapis.com/maps/api/js?v=3.exp");
?>
2) A "Load Javascript" block
var map;
function initialize() {
var mapOptions = {
zoom: 8,
mapTypeId:google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(-34.397, 150.644)
};
map = new google.maps.Map(document.getElementById('googleMap'),
mapOptions);
} //end function
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
3) The "Render HTML" command block (the only option changed from default is to perform a "POST").
As you can see it's all pretty basic, so convinced I'm doing something dumb, but as it's almost 1am I can't for the life of me see what it is ... HELP !!! 😲
Thanks in advance,
Tim