Listening for map errors on the CFMAP tag in ColdFusion

Readability

Listening for map errors on the CFMAP tag in ColdFusion

The fol­low­ing exam­ple shows how you can lis­ten for map errors on the <CFMAP> tag in Cold­Fu­sion and JavaScript using the onError attribute.










    



And the out­put of the <CFMAP> tag is as fol­lows:

The following example shows how you can listen for map errors on the <CFMAP> tag in ColdFusion and JavaScript using the onError attribute.

<html>
 
<cfajaximport params="#{googlemapkey='YourGoogleMapsAPIKeyHere'}#" />
 
<head>
<script type="text/javascript">
    function cfmap_onError(mapStatusCode, errorMessage) {
        alert("Uh oh, I wasn't able to find the specified address.\ncode: " + mapStatusCode);
    }
 
    function cfmap_onLoad() {
        alert("Map is loading.");
    }
</script>
</head>
<body style="padding:20px;">
 
    <cfmap name="map01"
            centerAddress="Qwertyville"
            onError="cfmap_onError"
            onLoad="cfmap_onLoad" />
 
</body>
</html>

And the output of the <CFMAP> tag is as follows:

Leave a Reply

Your email address will not be published.