Umbraco - Google Maps - XSLT - Macro

The Following Macro allows you to insert a Google Map on any Umbraco Page:


1) Create a XSLT file and accopanying Macro called "GoogleMap.xslt":

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxml="urn:schemas-microsoft-com:xslt"
  xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:CWS.Twitter="urn:CWS.Twitter"
  exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CWS.Twitter ">

<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="width" select="/macro/width" />
<xsl:variable name="height" select="/macro/height" />
<xsl:variable name="googleMapsLink" select="/macro/googleMapsLink" />
<xsl:template match="/">
<iframe width="{$width}" height="{$height}" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="{$googleMapsLink}&amp;output=embed">&nbsp;</iframe>
</xsl:template>
</xsl:stylesheet>

2) Add the Following Paramaters to the Macro:

a)
Alias: width
Name: width
Type: number

b)
Alias: height
Name: height
Type: number

c)
Alias: googleMapsLink
Name: googleMapsLink
Type: text

3) Enable the macro to 'Use in editor'

4) Insert the Macro on to your page.  You can get the googleMapsLink by clicking on the link Icon on any map in Google maps.










Comments

Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco