ClustrMaps and XHTML
This post isn’t very much about GeoHacking, but for everyone who uses the ClustrMaps application for their website might like this topic I am about to talk about.
As you might have notices, we have been working on the style of GeoHackr for the past couple of days; and one thing we wanted to work on was the website’s overall XHTML validation. We have a bit of a softspot for web standards!
One of the major problems that we were facing with the redesign was the code used for ClustrMaps. It is not XHTML compliant. This is the coding for Clustermaps:
1 <a href="http://www3.clustrmaps.com/counter/maps.php?url=http://geohackr.com"\
2 id="clustrMapsLink">
3 <img src="http://www3.clustrmaps.com/counter/index2.php?url=http://geohackr.com"\
4 style="border:0px;" alt="Locations of visitors to this page"\
5 title="Locations of visitors to this page" id="clustrMapsImg"\
6 onerror="this.onerror=null;\
7 this.src='http://www2.clustrmaps.com/images/clustrmaps-back-soon.jpg';\
8 document.getElementById('clustrMapsLink').href='http://www2.clustrmaps.com';" />
9 </a>
As you might see, the “onerror” portion of the IMG tag is not XHTML compliant. If you go to ClustrMaps website, they suggest the following:
VALIDATION/XHTML PROBLEMS: ClustrMaps HTML is causing my page to fail a W3C validation test, or my blog/service provider to modify or reject it. What can I do?As of 21st September 2006 you will see, on your Admin page, several choices for your HTML code, including one that is XHTML1.1 compliant. All are much cleaner than the older code. You can just substitute the new code for you old code.
Alternatively, if you want to stick with the old code, There are several issues that can be manually edited/fixed:
1. Neither the ‘border’ attribute nor the ‘onError’ code we use are XHTML 1.1 compliant; we’re working on a more elegant solution, but you could either live with it ‘as is’ for now (which is what we would recommend), or as a temporary ‘workaround’ you could manually edit out the offending code… in particular
(a) just delete
border=1
and
(b) also delete everything from the beginning of
onError
right up to the final closing ‘>’ (but don’t delete that closing ‘>’ itself).
Please note, however, that the onError code serves an extremely useful ‘failsafe’ purpose: in the very rare and unlikely event that our server goes down, you’ll just get a ‘broken image’ icon where the thumbnail map should be! In contrast, with the original onError code left alone, you would instead get a nice little ‘blank map with a holding message’.
2. Add a slash character “/” at the end of the img tag, and just before the “>” character, so that it looks like " /> " (without the quotes).
Your simplified HTML code would then look like this, with your own registered URL in place of the XXXXX below:
<a href=“http://clustrmaps.com/counter/maps.php?url=XXXXX” id=“clustrMapsLink”>
<img src=“http://clustrmaps.com/counter/index2.php?url=XXXXX” />
</a>
A more eligant solution, which we found in our research is the following:
1 <a href="http://www3.clustrmaps.com/counter/maps.php?url=http://geohackr.com" id="clustrMapsLink">
2 <img src="http://www3.clustrmaps.com/counter/index2.php?url=http://geohackr.com" style="border:0px;"\
3 alt="Locations of visitors to this page" title="Locations of visitors to this page"\
4 id="clustrMapsImg" />
5 <script type="text/javascript">
6 document.getElementById("clustrMapsImg").onerror = function(){
7 this.src='http://www2.clustrmaps.com/images/clustrmaps-back-soon.jpg';
8 };
9 document.getElementById('clustrMapsLink').onerror = function (){
10 this.href='http://www2.clustrmaps.com';
11 };
12 </script>
13 </a>
14 <
You just need to move the “onerror” functions to below the IMG tag. Hope this helps in the future for people wanting to use the ClustrMap app for your website.
Other Posts:
- 21 Aug 2010 ClustrMaps and XHTML
- 18 Aug 2010 Introducing Facebook Places
- 18 Aug 2010 Facebook Going Geo?
- 17 Aug 2010 Goodbye Yahoo Geo APIs
- 14 Mar 2010 Google Maps Goes Biking
- 25 Feb 2010 Location Awareness Takes a Small Step Back
- 22 Feb 2010 Gowalla Goes Android
- 19 Feb 2010 Welcome
- 01 Dec 2009 GIS Professional Salary Survey
- 28 Nov 2009 Happy GIS Day
- 28 Oct 2009 Info on OpenStreetMap Editors
- 28 Oct 2009 Google Releases Map Navigation for Android
- 26 Oct 2009 Twitter Onboard with Geolocation
- 23 Oct 2009 ESRI New JavaScript APIs
- 22 Oct 2009 Online Course on Python and Geoprocessing
- 22 Oct 2009 Loopt Acquires GraffitiGEO
- 20 Oct 2009 Mapathon Started in Atlanta, GA
- 15 Oct 2009 Sad News for VBA Fans
- 14 Oct 2009 Where 2.0 Call for Participation Deadline Extended
- 14 Oct 2009 US Census Bureau Releases 2009 Tiger/Line Shapefiles
- 12 Oct 2009 Google Maps Update, More Information
- 11 Oct 2009 Where 2.0 Call for Participation
- 11 Oct 2009 Augmented Reality, An Overview
- 07 Oct 2009 Google Maps Dump TeleAtlas
- 06 Oct 2009 BrightKite Hits the BIG 2.0
- 04 Oct 2009 Google Maps to Move Indoors?
- 02 Oct 2009 Twitter's Now Location Aware
- 11 Aug 2009 Welcome

