FIND OUT MORE

Display your business-critical information with confidence. Vicmap™ API – authoritative, current and clear.

Getting started

In order to use Vicmap API, a html page is required to host the map which will be displayed. In addition to that, a < script > tag to include the Vicmap API JavaScript mapping library.

For the actual map object, user can put the map object inside any block level element, which pretty much covers almost any HTML element on a page.

Below is the code snippet for displaying a map with panning and zooming controls; this is considered the basic usage of Vicmap API.

1  <html>
2  <head>
3  <script type="text/javascript" src="http://api.maps.vic.gov.au/vicmapapi/js/vicmapapi.js"></script>
4  <script type="text/javascript">
5      function init()
6      {
7          // "map" corresponds to the id of the div hosting the map
8          var map = new OpenLayers.Vicmap.Map("map");
9      }
10 </script>
11 <head>
12 <body onload="init()">
13 <div id="map" style="height:400px; width:600px; border:1px solid #000000;"></div>
14 </body>
15 </html>
 

In the code above a basic map with panning and zooming controls is created. Explanations for relevant lines of codes are given below:

  • In line 3, Vicmap JavaScript API is loaded using the <script> tag
  • In line 5, the OpenLayers.Vicmap.Map object is created within the init() JavaScript function
  • In line 8, the "map" variable refers to the element id of the container for the map object. The OpenLayers.Vicmap.Map constructor requires one argument. The argument must be an HTML element, or the ID of an HTML element.
  • In line 12, the map object is initialised upon the <body> tag's onload event
  • In line 13, a <div> element with the id "map" is created as a container for the map