Quick Search

Quick Search control helps you to search for any location in your embedded map; this is useful when running Local Knowledgeâ„¢ searches.

Including a search in a web page is quite straightforward. Follow these steps:

1. Add code to point to your available WebMap site.

a. Begin by opening the web page in a text editor. This is the page on which you want the search control.

b. Use the following line of code to point to your instance of Cadcorp SIS WebMap.

Copy
<script src="http://YOURSERVER/YOURWEBSITE/GetSearch.axd?embeddedControlId=mySearch
&controlTagId=searchPlaceholderTag
&showgeolocate=true
&searchSelectHandler=EmbeddedMap.resultSelectedHandler" 
type="text/javascript">
</script>

A note on the Search function

When using Quick Search you, the user, will define the function (i.e. what should happen when search results are displayed and when one of them is selected)

This is done using the searchSelectHandler:

In this example, the function passed to the Handler is EmbeddedMap.resultSelectedHandler.

This function is called when you select a location and you receive data about the location. For more help, contact Cadcorp Technical Services

The website embedding the search bar AND the WebMap website MUST be in the same domain.

2. Edit the web.config file

a. Open web.config in a suitable text editor.

b. You can find the config file in C:\inetpub\wwwroot\SISWebMap9.0.

c. Navigate to the <system.webServer> section and add this code snippet.

Copy
<add name="getsearch" verb="GET" path="GetSearch.axd" 
type="Cadcorp.Web.UI.Controls.NoticeBoard.EmbeddedSearch.EmbeddedSearchHandler,Cadcorp.Web.UI" />

There are two mandatory parameters that must be added to the URL:

  • controlTagId: This is the id of the element that the search bar will be added to (for example to add the search bar to this element:)
  • Copy
    <div id="SearchElement"></div>
  • Here the controlTagID is SearchElement
  • embeddedControlId: This is the id of the search bar; it must be unique.

Optional Parameters

There are other optional parameters that can be added to the URL to customise the search bar behaviour.

  • delay: The delay in milliseconds that the search bar will wait after you have finished typing until a search is performed.
  • showgeolocate: Set to true to show the geolocate button. If geolocate is not required omit it or set it to false.
  • initialamountofresultstofetch: The amount of results that will be retrieved when the search is first performed.
  • extraresultstofetch: The amount of results to fetch when the More button is clicked.
  • searches: A comma delimited list of search IDs to use; if missing or empty all the searches will be used.
  • osopenname: A comma delimited list of OS Open Name search ids to use; if missing or empty all the OS Open Name searches will be used.
  • osplaces: A comma delimited list of OS Place search IDs to use; if missing or empty all the OS Place searches will be used.

Finally if the website with the embedded search and the Cadcorp SIS WebMap website are on different domains, edit the web.config.

At the bottom of the web.config file, there is a block of code which is commented out by default:

<!-- Allow Cross Origin Resource Sharing (cors) for QuickSearch.asmx-->
<!-- <location path="QuickSearch.asmx">
 <system.webServer>
  <httpProtocol>
   <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
    <add name="Access-Control-Request-Method" value="GET,POST,OPTIONS" />
    <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
   </customHeaders>
  </httpProtocol> 
 </system.webServer>
</location> -->

Remove the comment, i.e. delete <!-- from <!-- <location and --> from the closing </location> -->