Skip to content

Plugin API Reference

Jeffrey Kemp edited this page Jul 15, 2019 · 39 revisions

The following javascript functions are supported. [Planned for v1.0]

It is recommended that the Static ID attribute be set on the reportmap region. This can then be used to refer to the correct instance of the reportmap object. If your Static ID is mymap, the jQuery plugin ID will be map_mymap.

Most methods are invoked via the jQuery plugin, e.g.

$("#map_mymap").reportmap("method to call");
  • click

    Search the report for a pin by its id value (as returned by the SQL query), and "click" it.

    Example:

    $("#map_mymap").reportmap("click", "12345");
    
  • geolocate

    Search for the user device's location using navigator.geolocation.getCurrentPosition, if possible (and allowed by the user).

    Example:

    $("#map_mymap").reportmap("geolocate");
    
  • gotoAddress

    Search the map for an address using google.maps.Geocoder; if found, put a pin at that location and raise addressfound trigger.

    Example:

    $("#map_mymap").reportmap("gotoAddress", "5 The Esplanade, Perth");
    
  • gotoPos

    Place or move the user's pin to the given location.

    Example:

    $("#map_mymap").reportmap("gotoPos", -24.8848, 113.6566);
    
  • gotoPosByString

    Parse a string as a lat,long pair and put a pin at that location.

    Example:

    $("#map_mymap").reportmap("gotoPosByString", "-24.8848,113.6566");
    
  • searchAddress

    Search for the closest address to the given lat / long position using google.maps.Geocoder and raise addressfound trigger if successful.

    Example:

    $("#map_mymap").reportmap("searchAddress", -24.8848, 113.6566);
    
  • google.maps.Map

    The Google Map object created by the plugin can be used directly; this supports the full range of capabilities as documented here.

    Examples:

    • Zoom the map to a particular level (0..23):

      $("#map_mymap").reportmap("instance").map.setZoom(13);
      
    • Pan the map to a particular location:

      $("#map_mymap").reportmap("instance").map.panTo({lat:-24.8848, lng:113.6566});
      
    • Pan and zoom the map so that it shows the given extent:

      $("#map_mymap").reportmap("instance").map.fitBounds({
        south:-33.9337,
        west: 151.070,
        north:-33.7611,
        east: 151.3385
      });
      

      or

      var southwest = {-33.9337, 151.070},
          northeast = {-33.7611, 151.3385};
      $("#map_mymap").reportmap("instance").map.fitBounds(new google.maps.LatLngBounds(southwest,northeast));
      
    • Set tilt:

      $("#map_mymap").reportmap("instance").map.setTilt(45);
      
    • Change map type:

      $("#map_mymap").reportmap("instance").map.setMapTypeId("hybrid");
      $("#map_mymap").reportmap("instance").map.setMapTypeId("roadmap");
      $("#map_mymap").reportmap("instance").map.setMapTypeId("satellite");
      $("#map_mymap").reportmap("instance").map.setMapTypeId("terrain");
      
    • Get the map's current center location:

      var pos = $("#map_mymap").reportmap("instance").map.getCenter();
      console.log(pos.lat(), pos.lng());
      
    • Get the map's current bounds:

      var b = $("#map_mymap").reportmap("instance").map.getBounds();
      console.log(b.getNorthEast().toString());
      console.log(b.getSouthWest().toString());
      
Clone this wiki locally