Step 3: Create the Virtual Earth Map Location and Customize the XSL [Search Server 2008]

After you verify that the HTML to RSS federated connector is working (see Step 2: Add the Code for the Federated Search Virtual Earth Map Connector [Search Server 2008] ), you need to create a federated location for it. You can then add a Federated Results Web Part that displays results from the location. The tasks involved include:

  • Creating the Federated location

  • Customizing the Federated location's XSL property

  • Adding the Federated Results Web Part

  • Testing the Federated Search Virtual Earth Map Connector

To create the federated location

  1. On the Search Server 2008 Administration page, click Federated Locations, and then click New Location.

  2. In the Location Name field and Display Name field, type the names you want to use for the location, and the text you want it to display as its name..

  3. In the Description field, type text to describe the location, such as Live Search Results.

  4. In the Version field, type 1.0.

  5. For the Location type field, click OpenSearch 1.0/1.1.

  6. In the Query Template field, type the URL for the RSS feed you created (for example, http://localhost/Default.aspx?q={searchTerms}).

  7. In the "More Results" Link Template field, type http://{searchTerms}.

  8. Click OK.

To customize the XSL property of the federated location

  1. On the Search Administration page, click Federated Locations.

  2. Under Location Display Name, click the name of your location.

  3. Expand the Display Information node.

  4. Under Federated Search Results Metadata, clear the Use Default Formatting check box.

  5. Click the ellipsis (…) button to open the Text Entry window for the location's XSL property.

  6. Add this script under the <xsl:call-template name="MainTemplate.description"> section (directly under that section's </xsl:call-template> closing tag).

    <script type="text/javascript" language="javascript" xmlns=""><xsl:text disable-output-escaping="yes"><![CDATA[<!--document.write('<script type="text/javascript" language="javascript" src=""></script>');//-->]]></xsl:text>var map = null;// Set page event handlers for onload and unloadif (window.attachEvent) {window.attachEvent("onload", Page_Load);window.attachEvent("onunload", Page_Unload);} else {window.addEventListener("DOMContentLoaded", Page_Load, false);window.addEventListener("unload", Page_Unload, false);}// Load mapfunction Page_Load() {GetMap();}// Clean up all objectsfunction Page_Unload() {if (map!=null) {map.Dispose();map = null;}}
    //Pass the latitude and longitude values from the RSS feed to Virtual Earthfunction GetMap(){map = new VEMap('FedMapDiv');map.SetDashboardSize(VEDashboardSize.Small);map.LoadMap(new VELatLong(<xsl:value-of select="latitude"/>,<xsl:value-of select="longitude"/>), 10, 'r', false);var mapdiv = document.getElementById("FedMapDiv");var yPos = mapdiv.clientHeight - 195;var location = new VELatLong(<xsl:value-of select="latitude"/>,<xsl:value-of select="longitude"/>);var shape = new VEShape(VEShapeType.Pushpin, location);map.AddShape(shape);map.SetCenterAndZoom(location, 12);}</script><div id='FedMapDiv' style="position:relative; width:300px; height:300px;"></div>
  7. Click OK to close the Text Entry window.

  8. On the Edit Federated Location page, click OK to save the changes to the federated location.

To add the Federated Results Web Part to your Search Server site

  1. From the Search Center, go to the search results page in the path http://YourServerName/results.aspx.

  2. Click Site Actions, and then click Edit Page.

  3. In the Right Zone, click Add a Web Part.

  4. In Suggested Parts for Right Zone, select Federated Results, and then click Add.

  5. Click Edit for the new Federated Results Web Part, and then click Modify Shared Web Part.

  6. In Location Properties, click the name of the location that you created from the Location list.

  7. In Display Properties, ensure that the Retrieve Results Asynchronously check box is cleared. The Web Part must load synchronously for the ECMAScript (JScript, JavaScript) in the XSL property to work correctly.

  8. Click OK.

  9. Click Exit Edit Mode to close the Edit page.

To test the HTML to RSS Federated Connector

  1. Go to the Search Center Home page in the path http://YourServerName/default.aspx.

  2. Type a valid address, consisting of street address, city, and state, in the search box.

  3. If the Federated Search Virtual Earth Map Connector is working, you should see an interactive Virtual Earth map on the search results page.

See Also

Community Additions