Embedding a map into any web page
Cadcorp SIS WebMap allows you to embed mapping and controls into web pages.
- Create the Map you wish to embed using the WebMap Admin Interface. Ensure the Allow Embedded Map option is enabled.
- WebMap includes a sample embedded map page index.html; this is included with your installation files. You can usually find it here: C:\inetpub\wwwroot\SISWebMap\EmbeddedMapSample
- For a preview of the file, double-click to open in a browser.
- To change the instance of WebMap used for the embedded map open index.html in any code editor of your choice. Navigate to line 23 and change the specifications.
<script src="http://YOURSERVER/YOURWEBSITE/GetMap.axd?controlTag=MapPlaceholderTag&x=530284 &y=179551&resolution=1.2&showsymbol=true&controls=panzoom" type="text/javascript"></script>
YOURSERVER : Computer your website is being served from.
YOURWEBSITE : website name for WebMap
The completed URL should point to the WebMap IIS application folder e.g https://ws.cadcorp.com/webmap/GetMap.axd?
Note: The Cadcorp SIS WebMap installer will automatically add this information but it is worth checking if you are unable to see the embedded map.
This will display the map at the top of the web page.
To embed a map on a page on a different server to that hosting SIS WebMap 9, change the Proxy Host value to point to the correct WebMap server.
Open the map Settings (refer to FirstMap Settings).
Change the Proxy Host value from proxy.axd? to your full path, i.e.
http://maps.MyCouncil.gov.uk/WebMap/proxy.axd?
Click Update.
Note: If the embedded website and WebMap are on different domains, open the web.config file (found in C:\inetpub\wwwroot\SISWebMap9) and add the lines shown in red to the <httpProtocol> section.
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By"/>
<add name="X-XSS-Protection" value="1;mode=block"/>
<add name="X-Content-Type-Options" value="nosniff"/>
<add name="Cache-control" value="no-store"/>
<add name="X-Frame-Options" value="deny"/>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Credentials" value="true"/>
<add name="Access-Control-Allow-Methods"
value="GET,POST,OPTIONS"/>
<add name="Access-Control-Allow-Headers"
value="Origin, X-Requested-With, Content-Type, Accept"/>
</customHeaders>
</httpProtocol>
You can set more parameters that control the initial map view and other controls.
-
mapname
mapname=FirstMap
Defines the map which is to be emebedded. Use the map name which is defined in the Admin Interface
- X and Y coordinate pairs
&x=123456,&y=123456
Centres the map on the supplied X and Y coordinates. X and Y values.
- Resolution or scale - The initial view resolution/scale
&resolution=0.2 or &scale=1367
Opens the map already zoomed to a defined view scale or resolution. This must match one of the scales or resolutions defined in the web.config.
- MapID
&MapID=embeddedmap
This defines the ID of the map object to be rendered. This defaults to testMap if not specified and will allow user to access the map object via code.
- ShowSymbol
showsymbol=true
This can be either true or false and places a point symbol on the X and Y coordinates specified earlier. The symbol used is specified in the webMapLayersConfig.db database, in the EmbeddableMapIcons table. You define the number of the icon you need from the icons table.
- Controls - a comma separated list of map controls.
&controls=keymap,scaleline,layerswitcher,mouseposition,panzoom,featureinfo
keymap
adds a keymap control to the map object.
scaleline\scalebar
Adds a scale bar to the map object.(either acceptable; both produce the same scale bar)
layerswitcher
adds a control for the user to select which layers to turn on or off.
mouseposition
adds a control displaying the coordinates of the mouse cursor.
panzoom
adds a control to pan and zoom on the map (not necessary for mouse wheel zooming or click & drag panning).
featureinfo
allows interaction with the embedded map to return information about a feature when it is selected.
All modern smartphones and tablets routinely make use of gestures to interact with their content.
SIS WebMap is perfectly primed for this seamless smartphone experience; you can pan the map with your finger and pinch-to-zoom.
Any additional parameters added to the embedded map like the layer switcher or keymap can also be handled easily with touch screen gestures.
To use the Get Feature information tool on an embedded map:
- Ensure the website containing the embedded map is on the same domain as the URL in the embedded map script tag (due to browser security) (OR)
- If the feature information is on a different domain, flag this domain within the webMapLayersConfig.db as safe to be accessed via proxy. This prevents any interaction with unauthorised sites that could interfere with or harm the application.
Note: Cadcorp SIS WebMap is installed with a number of safe domains, but you can add to this list in the ProxyConfiguration table in the webMapLayersConfig.db- simply enter the domain name as a new row in the table.