-
-
Notifications
You must be signed in to change notification settings - Fork 16
Plugin API Reference
The following javascript functions are supported. [Planned for v1.0]
Each function takes at minimum the opt_xxx object for the map region. It is recommended that the Static ID attribute be set on the reportmap region. This can then be used to derive the opt_xxx object. For example, if Static ID is "mymap", the opt_xxx object will be opt_mymap
.
-
reportmap.click
Search the report for a pin by its
id
value (as returned by the SQL query), and "click" it.Example:
reportmap.click (opt_mymap, "12345");
-
reportmap.geolocate
Search for the user device's location using
navigator.geolocation.getCurrentPosition
, if possible (and allowed by the user).Example:
reportmap.geolocate (opt_mymap);
-
reportmap.gotoAddress
Search the map for an address using
google.maps.Geocoder
; if found, put a pin at that location and raise addressfound trigger.Example:
reportmap.gotoAddress (opt_mymap, "5 The Esplanade, Perth");
-
reportmap.gotoPos
Place or move the user's pin to the given location.
Example:
reportmap.gotoPos (opt_mymap, -24.8848, 113.6566);
-
reportmap.gotoPosByString
Parse a string as a lat,long pair and put a pin at that location.
Example:
reportmap.gotoPosByString (opt_mymap, "-24.8848,113.6566");
-
reportmap.parseLatLng
Parse a string as a lat,long pair and return a
google.maps.LatLng
if possible.Example:
reportmap.parseLatLng ("-24.8848,113.6566");
-
reportmap.searchAddress
Search for the closest address to the given lat / long position using
google.maps.Geocoder
and raise addressfound trigger if successful.Example:
reportmap.searchAddress (opt_mymap, -24.8848, 113.6566);
-
google.maps.Map
The Google Map object created by the plugin can be used directly via
opt_mymap.map
; this supports the full range of capabilities as documented here.Examples:
-
Zoom the map to a particular level (0..23):
opt_mymap.map.setZoom(13);
-
Pan the map to a particular location:
opt_mymap.map.panTo({lat:-24.8848, lng:113.6566});
-
Pan and zoom the map so that it shows the given extent:
opt_mymap.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}; opt_mymap.map.fitBounds(new google.maps.LatLngBounds(southwest,northeast));
-
Set tilt:
opt_mymap.map.setTilt(45);
-
Change map type:
opt_mymap.map.setMapTypeId("hybrid"); opt_mymap.map.setMapTypeId("roadmap"); opt_mymap.map.setMapTypeId("satellite"); opt_mymap.map.setMapTypeId("terrain");
-
Get the map's current center location:
var pos = opt_mymap.map.getCenter(); console.log(pos.lat(), pos.lng());
-
Get the map's current bounds:
var b = opt_mymap.map.getBounds(); console.log(b.getNorthEast().toString()); console.log(b.getSouthWest().toString());
-