Hi Everyone,
here is my code - I've tried using the google maps api and other tutorials, but I can't seem to get the code right. It either displays the default icon or no icon at all.
Here is the unaltered code -
<script type="text/javascript">
//<![CDATA[
<?php if ($er_imglayout == 4 && $row->image2) { ?>
function domap()
<?php } else { ?>
function ezrealtymap()
<?php } ?>
{
// Check to see if this browser can run the Google API
if (GBrowserIsCompatible()) {
gmarkers = [];
htmls = [];
to_htmls = [];
from_htmls = [];
i=0;
// Display the map, with some controls and set the initial location
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng( <?php echo $row->declat;?>,<?php echo $row->declong;?>), <?php echo $er_mapres;?>);
map.setMapType(<?php echo $er_mapview;?>);
// Set up three markers with info windows
var point = new GLatLng( <?php echo $row->declat;?>,<?php echo $row->declong;?>);
var marker = createMarker(point,"<?php echo stripslashes($row->adline);?>","<?php echo stripslashes($row->adline);?>")
map.addOverlay(marker);
} else {
// display a warning if the browser was not compatible
alert("<?php echo _EZREALTY_MAPPING_INCOMPATIBLE;?>");
}
}
// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/
// http://www.econym.demon.co.uk/googlemaps/
//]]>
// A function to create the marker and set up the event window
function createMarker(point,name,html) {
var marker = new GMarker(point);
// The info window version with the "to here" form open
to_htmls[i] = html + '<br /><?php echo _EZREALTY_MAP_DIRECTIONS;?>: <strong><?php echo _EZREALTY_MAP_TOHERE;?></strong> - <a href="javascript:fromhere(' + i + ')"><?php echo _EZREALTY_MAP_FROMHERE;?></a>' +
'<br /><?php echo _EZREALTY_MAP_START;?>:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
'<input type="text" size="40" maxlength="40" name="saddr" id="saddr" value="" /><br />' +
'<input value="<?php echo _EZREALTY_MAP_DIRECTIONS;?>" type="submit">' +
'<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() +
// "(" + name + ")" +
'"/>';
// The info window version with the "to here" form open
from_htmls[i] = html + '<br /><?php echo _EZREALTY_MAP_DIRECTIONS;?>: <a href="javascript:tohere(' + i + ')"><?php echo _EZREALTY_MAP_TOHERE;?></a> - <strong><?php echo _EZREALTY_MAP_FROMHERE;?></strong>' +
'<br /><?php echo _EZREALTY_MAP_END;?>:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
'<input type="text" size="40" maxlength="40" name="daddr" id="daddr" value="" /><br />' +
'<input value="<?php echo _EZREALTY_MAP_DIRECTIONS;?>" type="submit">' +
'<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
// "(" + name + ")" +
'"/>';
// The inactive version of the direction info
html = html + '<br /><?php echo _EZREALTY_MAP_DIRECTIONS;?>: <a href="javascript:tohere('+i+')"><?php echo _EZREALTY_MAP_TOHERE;?></a> - <a href="javascript:fromhere('+i+')"><?php echo _EZREALTY_MAP_FROMHERE;?></a>';
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
gmarkers[i] = marker;
htmls[i] = html;
i++;
return marker;
}
// functions that open the directions forms
function tohere(i) {
gmarkers[i].openInfoWindowHtml(to_htmls[i]);
}
function fromhere(i) {
gmarkers[i].openInfoWindowHtml(from_htmls[i]);
}
</script>