步骤 3:创建 Virtual Earth 映射位置并自定义 XSL

备注

本主题介绍 Infrastructure Update for Microsoft Office Servers中的功能。若要下载此更新,请参阅 SharePoint Server 2007 基础结构更新说明:2008 年 7 月 15 日

在验证了“HTML 至 RSS”联合连接器可以工作之后(请参阅步骤 2:为联合搜索 Virtual Earth 映射连接器添加代码),需要为其创建一个联合位置。然后可以添加一个显示该位置中的结果的联合结果 Web 部件。涉及的任务包括:

  • 创建联合位置

  • 自定义联合位置的 XSL 属性

  • 添加联合结果 Web 部件

  • 测试联合搜索 Virtual Earth 映射连接器

创建联合位置

  1. 在 Office SharePoint Server 2007 共享服务提供程序的“搜索管理”页上,单击“联合位置”,然后单击“新建位置”。

  2. 在“位置名称”字段和“显示名称”字段中,键入想要用于位置的名称以及想要显示为位置名称的文本。

  3. 在“说明”字段中,键入文本来描述位置(例如 Live Search 结果)。

  4. 在“版本”字段中,键入“1.0”。

  5. 对于“位置类型”字段,请单击“OpenSearch 1.0/1.1”。

  6. 在“查询模板”字段中,键入所创建的 RSS 源的 URL(例如,https://localhost/Default.aspx?q={searchTerms})。

  7. 在“‘更多结果’链接模板”字段中,键入 http:// search.live.com/results.aspx?q={searchTerms}。

  8. 单击“确定”。

自定义联合位置的 XSL 属性

  1. 在“搜索管理”页面上,单击“联合位置”。

  2. 在“位置显示名称”下面,单击您的位置的名称。

  3. 展开“显示信息”节点。

  4. 在“联合搜索结果显示元数据”下面,清除“使用默认格式”复选框。

  5. 单击省略号 (…) 按钮以针对位置的 XSL 属性打开“文本输入”窗口。

  6. 在 <xsl:call-template name="MainTemplate.description"> 部分下面添加此脚本(直接在该部分的 </xsl:call-template> 结束标记下面添加)。

    <script type="text/javascript" language="javascript" >
    <xsl:text disable-output-escaping="yes">
    <![CDATA[
    <!--
    document.write('<script type="text/javascript" language="javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script>');
    //-->
    ]]>
    </xsl:text>
    var map = null;
    // Set page event handlers for onload and unload
    if (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 map
    function Page_Load() {
    GetMap();
    }
    // Clean up all objects
    function Page_Unload() {
    if (map!=null) {
    map.Dispose();
    map = null;
    }
    }
    //Pass the latitude and longitude values from the RSS feed to Virtual Earth
    function 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. 单击“确定”以关闭“文本输入”窗口。

  8. 在“编辑联合位置”页上,单击“确定”以保存对联合位置所做的更改。

将联合结果 Web 部件添加到您的 Office SharePoint Server 2007 网站

  1. 从搜索中心中,转到 http://YourServerName/results.aspx 路径中的搜索结果页。

  2. 单击“网站操作”,然后单击“编辑网页”。

  3. 在“右侧区域”中,单击“添加 Web 部件”。

  4. 在“为右侧区域建议的 Web 部件”中,选择“联合结果”,然后单击“添加”。

  5. 对此新联合结果 Web 部件单击“编辑”,然后单击“修改共享 Web 部件”。

  6. 在“位置属性”中,从“位置”列表中单击您创建的位置的名称。

  7. 在“显示属性”中,确保清除“异步检索结果”复选框。Web 部件必须同步加载才能使 XSL 属性中的 ECMAScript(JScript 和 JavaScript)正常工作。

  8. 单击“确定”。

  9. 单击“退出编辑模式”以关闭“编辑”页面。

测试“HTML 至 RSS”联合连接器

  1. 转到 http://您的服务器名称/default.aspx 路径中的搜索中心主页。

  2. 在搜索框中键入一个由省/自治区、市/县以及街道地址组成的有效地址。

  3. 如果联合搜索 Virtual Earth 映射连接器正在工作,则应该在搜索结果页上看到一个交互式 Virtual Earth 映射。

See Also

概念

步骤 1:设置用于联合搜索 Virtual Earth 映射连接器的项目

步骤 2:为联合搜索 Virtual Earth 映射连接器添加代码