// AJAX call, iterate over resulting postcodes, and call
// usePointFromPostcode with a callback to add a marker.
[code]
...
var url="/api/eh52gj";
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport) {
var addrs = transport.responseXML.getElementsByTagName('addrs');
for (var i = 0; i < stores.length; i++) {
var postcode =
addrs[i].getElementsByTagName('postcode')[0]...
.childNodes[0].nodeValue;
usePointFromPostcode(postcode, placeMarkerAtPoint);
}
}
});
...
[/code]// This function _geocodes_ a postcode using LocalSearch, and if as
// above, the placeMarkerAtPoint callback is given, a marker ovarlay
// is placed on the map.
[code]
function usePointFromPostcode(postcode, callbackFunction) {
localSearch = new google.search.LocalSearch();
localSearch.setSearchCompleteCallback(null, function() {
if (localSearch.results[0]) {
var resultLat = localSearch.results[0].lat;
var resultLng = localSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
callbackFunction(point);
map.panTo(point);
}
});localSearch.execute(postcode + ", UK"); } [/code]
Many Thanks, Max -- Max Manders max@xxx.xxx.xxx http://maxmanders.co.uk - ---------------------------------------------------------------------- You can find the EdLUG mailing list FAQ list at: http://www.edlug.org.uk/list_faq.html
|
This archive is kept by wibble+RM@xxx.xxx.xxx Morpheux | HomePage |