Interacting with the Map
There are various different ways of using iShare to integrate maps within a website. Have a look at the following examples:
Centre the Map on a Point
In this event, the zoom actually refers to the desired width of the map in metres. This is for backwards compatibility. If any of easting, northing or zoom are not supplied the current values are used.
JQuery
jQuery('#atMap').trigger('mapMove', [{easting: easting_value, northing: northing_value, zoom: zoom_value}])
JavaScript
The map will be displayed at the My Maps Startup view unless you specify a “view” parameter on the createMap call. The following examples show how to display a point at a Zoom Level of 2000 and Easting and Northing coordinates of 495553 and 175654 respectively in both a Solo or Lite map.
soloMap.createMap('atMap', { themeName: 'base', mapSource: 'Workshop/AllMaps', layers: 'Primary Schools,Secondary Schools', view:{easting:495553, northing:175654, zoom:2000} });
<script type="text/javascript"> liteMap.createMap('atMap', { mapSource: 'Workshop/AllMaps', layers: 'Primary Schools,Secondary Schools', view:{easting:495553, northing:175654, zoom:2000} }); </script>
URL
?StartEasting=easting_value&StartNorthing=northing_value &StartZoom=zoom_value
Find a Feature on the Map
This can be done by searching a given layer for a value, the feature with a specified field matching that value is zoomed to.
JQuery
jQuery('#atMap').trigger('searchISM',[layer_name,field_name,search_string]);
JavaScript
window.astun.mapWrapper.searchISMLayer( layer, field, value, function( response ) { window.astun.mapWrapper.showResults( response ); } );
Set the Scale for the Map
The previous methods for a point can be used provided you know the width in metres you want to zoom to.
JavaScript
You can zoom to a scale or zoom level using the OpenLayer map object window.astun.mapWrapper.map and manipulate it directly.
astun.mapWrapper.map.zoomToScale()
and
astun.mapWrapper.map.zoomTo()
This method of access to the map is deprecated and may be removed in future versions - but only once we provide alternative methods of getting to the map object.
Add or Remove Layers from the Map
A full list of available layers can be found in your map configuration in iShare Studio; the layers are under Map Sources. The layer names are case-sensitive.
JQuery
jQuery('#atMap').trigger('showLayer',[layer_name]) jQuery('#atMap').trigger('hideLayer',[layer_name]) jQuery('#atMap').trigger('toggleLayer',[layer_name])
Only one layer can be specified at a time.
JavaScript
window.astun.mapWrapper.addISMLayer(layer_name); window.astun.mapWrapper.removeISMLayer(layer_name); window.astun.mapWrapper.setISMLayers(layer_names);
layer_names in the last method are a comma separated list and replace the existing set of layers on the map. You can get the current set of layers too:
window.astun.mapWrapper.getISMLayers();
URL
?l=layer_names
or
?layers=layer_names
These are equivalent, layer_names are a comma separated list.