XSLT and javascript in google maps
-
Tuesday, July 12, 2011 2:08 PM
Hi to all
I am relatively new to SP, and i want to make a page using a dataview to show all countries in a list i have made like layers in google maps.
Although i have made it staticaly, when i try to mix javascript and the xslt in the dataview with SP designer, everything gets ruined,
Here is the code
<XSL>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls" >
<xsl:call-template name="dvt_1"/>
<script type="text/javascript">
function initialize() {
var center= new google.maps.LatLng(49.210420445650286, 5.18359375);
var myOptions = {
zoom: 4,
center: center,
mapTypeId: google.maps.MapTypeId.TERRAIN
}var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
google.maps.event.addListener(map, 'click', function() {
alert('map clicked');
});
<![CDATA[
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>]]>}
</script> </xsl:template>
<xsl:template name="dvt_1">
<script type="text/javascript"></script> </xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"/>
<xsl:for-each select="$Rows">
<xsl:call-template name="dvt_1.rowview"/>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<xsl:text>var</xsl:text>
<xsl:value-of select="@code"/>
<xsl:text> = new google.maps.KmlLayer('http://domain/</xsl:text>
<xsl:value-of select="@code"/>
<xsl:text> .kml', {suppressInfoWindows: true});</xsl:text>
<xsl:value-of select="@code"/>
<xsl:text>.setMap(map);</xsl:text>
<xsl:value-of select="@code"/>
<xsl:text>.set('preserveViewport', true);</xsl:text>
<xsl:text>google.maps.event.addListener(</xsl:text>
<xsl:value-of select="@code"/>
<xsl:text>, 'click', function(kmlEvent) {var text = kmlEvent.featureData.name;window.location.href='http://en.wikipedia.org/wiki/</xsl:text>
<xsl:value-of select="@code"/>
<xsl:text>'; }); </xsl:text>
</xsl:template>
</xsl:stylesheet> </XSL>Unfortunately i dont know how to fix this, any help would be highly appreciated
Thank you in advance
Tolis- Moved by Mike Walsh FIN Tuesday, July 12, 2011 2:46 PM using spd (From:SharePoint - Development and Programming (pre-SharePoint 2010))

