Embedding a JMap Web Deployment Into Your own Application
JMap Web's design allows the embedding of JMap Web deployments into your own web applications. This section details the necessary steps to enable application embedding.
Copying the JMap Web Libraries and Dependencies to Your Web Server
Your deployed JMap Web applications, as they are now being served by JMap's embedded Tomcat instance, contain the libraries and web services required for application embedding. Your application's files are located in the /applications/deployed directory of your JMap Server.
Among those files is the jmap directory. It contains all necessary resources required to embed your JMap deployment. This directory and its contents must be copied to your web server and be accessible by your web application's pages.
JMap Web's dependencies will be loaded as part of the initialization process prior to displaying the map. For more details regarding the initialization process refer to the JMap Web's Initialization Process section of this document.
|
Authorizing Cross-Origin Resource Sharing
In order to allow JMap Web Deployments to be embedded, a few tweaks to your deployment's web.xml files are necessary.
|
1. Enable HTTP Authentication for the JMapLoginFilter_index filter.
<filter> |
2. Instanciate and map the CORS filter. Add the following declarations before the first ByPassFilter mapping.
<filter> |
Embedding a map
Once the jmap directory is copied to your web server, you will need to add the following script references in the <head> portion of the document where you wish to embed your deployment:
<script type="text/JavaScript" src="jmap/vendor/jquery-1.9.1.min.js"></script> |
|
To initialize the map, you will need to provide an empty div into which the map will be created.
<div id="map" style="height: 600px; width: 600px;"></div> |
Tip: Don't see the map? Make sure your div is properly sized. |
Include the following Javascript to trigger map initialization.
<script type="text/JavaScript"> |
The JMap.initialize function that is called above is the same as the one that was detailed previously here. You may customize the embedded application by specifying those same configuration properties in a mapConfig object literal supplied in the options argument.
embed_example.html
Included in your deployed application's directory is an embed_example.html file. It serves as an example of a JMap Web embedded application. Open that file in a text editor to see how application embedding is done.
You can also copy that file and the jmap directory to a seperate web server in order to confirm that Cross-Origin Resource Sharing was properly enabled.
Dealing with Authentication
If you enabled controlled access on your JMap Web deployment, you will need to authenticate as a JMap User prior to initializing the map.
The following is provided as an example and IS NOT a recommended way of authenticating yourself to JMap Server:
<script type="text/JavaScript"> |