Geomark Web Service - JavaScript API

class GeomarkClient

GeomarkClient(url)

Construct a new Geomark client that is connected to a specific Geomark web service (e.g. https://apps.gov.bc.ca/pub/geomark).

Parameter Type Description
url string The url to the Geomark web service.

copyGeomark(url)

Construct a new new geomark by copying the geometries from one or more existing geomarks using the Create Geomark Copy REST API.

The parameters to the method are passed in using a Javascript object (map). See the Create Geomark Copy REST API for the list of supported parameters.

In addition the request must include the 'callback' parameter which must be a Javascript function. This function will be called with a single argument containing the geomark info Javascript object if the geomark was created successfully. If there was a data error a JavaScript object with the error details will be returned. Applications may receive other undocumented results if the wrong URLs are used or the server is not available.

The following code fragment shows an example of using the API.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://apps.gov.bc.ca/pub/geomark/js/geomark.js" ></script>>
<script type="text/javascript">
  function copyGeomarkExample() {
    var baseUrl = 'https://apps.gov.bc.ca/pub/geomark';
    var client = new GeomarkClient(baseUrl);
    var geomarks = [
      baseUrl + '/geomarks/gm-abcdefghijklmnopqrstuv0bcislands'
      // or 'gm-abcdefghijklmnopqrstuv0bcislands'
    ];
    client.copyGeomark({
      'geomarkUrl': geomarks,
      'callback': function(geomarkInfo) {
        var geomarkId = geomarkInfo.id;
        if (geomarkId) { 
          alert('Created geomark: ' + geomarkInfo.id);
        } else {
          alert('Error creating geomark:' + geomarkInfo.geomarkUrl_Error);
        }
      }
    });
  }
</script>

Parameter Type Description
url string The url to the Geomark web service.

createGeomark(url)

Construct a new new geomark from a string containg a KML, GML, or WKT geometry using the Create Geomark REST API.

The parameters to the method are passed in using a Javascript object (map). See the Create Geomark REST API for the list of supported parameters.

In addition the request must include the 'callback' parameter which must be a Javascript function. This function will be called with a single argument containing the geomark info Javascript object if the geomark was created successfully. If there was a data error a JavaScript object with the error details will be returned. Applications may receive other undocumented results if the wrong URLs are used or the server is not available.

The following code fragment shows an example of using the API.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://apps.gov.bc.ca/pub/geomark/js/geomark.js" ></script>>
<script type="text/javascript">
  function createGeomarkExample() {
    var baseUrl = 'https://' + location.hostname + '/pub/geomark';
    var client = new GeomarkClient(baseUrl);
    var geomarks = [
      baseUrl + '/geomarks/gm-abcdefghijklmnopqrstuv0bcislands'
    ];
    client.createGeomark({
      'body': 'SRID=4326;POINT(-128 54)',
      'format': 'wkt',
      'callback': function(geomarkInfo) {
        var geomarkId = geomarkInfo.id;
        if (geomarkId) { 
          alert('Created geomark: ' + geomarkInfo.id);
        } else {
          alert('Error creating geomark:' + geomarkInfo.geomarkUrl_Error);
        }
      }
    });
  }
</script>

Parameter Type Description
url string The url to the Geomark web service.

getGeomarkBoundingBox(url)

Get the geomark bounding box using the Get Geomark BoundingBox REST API.

The parameters to the method are passed in using a Javascript object (map). See the Get Geomark BoundingBox REST API for the list of supported parameters.

In addition the request must include the 'callback' parameter which must be a Javascript function. This function will be called with a single argument containing the geomark bounding box Javascript object if the geomark was found successfully. If there was an error this will be recorded in the Javascript error console.

The following code fragment shows an example of using the API.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://apps.gov.bc.ca/pub/geomark/js/geomark.js" ></script>>
<script type="text/javascript">
  function getGeomarkBoundingBoxExample() {
    var baseUrl = 'https://apps.gov.bc.ca/pub/geomark';
    var client = new GeomarkClient(baseUrl);
    client.getGeomarkBoundingBox({
      'geomarkId': 'gm-abcdefghijklmnopqrstuv0bcislands',
      'srid': 4326,
      'callback': function(geomarkBoundingBox) {
        alert('Found geomark: ' + geomarkBoundingBox.geometry);
      }
    });
  }
</script>

Parameter Type Description
url string The url to the Geomark web service.

getGeomarkFeature(url)

Get the geomark feature using the Get Geomark Feature REST API.

The parameters to the method are passed in using a Javascript object (map). See the Get Geomark Feature REST API for the list of supported parameters.

In addition the request must include the 'callback' parameter which must be a Javascript function. This function will be called with a single argument containing the geomark feature Javascript object if the geomark was found successfully. If there was an error this will be recorded in the Javascript error console.

The following code fragment shows an example of using the API.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://apps.gov.bc.ca/pub/geomark/js/geomark.js" ></script>>
<script type="text/javascript">
  function getGeomarkFeatureExample() {
    var baseUrl = 'https://apps.gov.bc.ca/pub/geomark';
    var client = new GeomarkClient(baseUrl);
    client.getGeomarkFeature({
      'geomarkId': 'gm-abcdefghijklmnopqrstuv0bcislands',
      'srid': 4326,
      'callback': function(geomarkFeature) {
        alert('Found geomark: ' + geomarkFeature.geometry);
      }
    });
  }
</script>

Parameter Type Description
url string The url to the Geomark web service.

getGeomarkInfo(url)

Get the geomark info using the Get Geomark Info REST API.

The parameters to the method are passed in using a Javascript object (map). See the Get Geomark Info REST API for the list of supported parameters.

In addition the request must include the 'callback' parameter which must be a Javascript function. This function will be called with a single argument containing the geomark info Javascript object if the geomark was found successfully. If there was an error this will be recorded in the Javascript error console.

The following code fragment shows an example of using the API.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://apps.gov.bc.ca/pub/geomark/js/geomark.js" ></script>>
<script type="text/javascript">
  function getGeomarkInfoExample() {
    var baseUrl = 'https://apps.gov.bc.ca/pub/geomark';
    var client = new GeomarkClient(baseUrl);
    client.getGeomarkInfo({
      'geomarkId': 'gm-abcdefghijklmnopqrstuv0bcislands',
      'callback': function(geomarkInfo) {
        alert('Found geomark: ' + geomarkInfo.id);
      }
    });
  }
</script>

Parameter Type Description
url string The url to the Geomark web service.

getGeomarkParts(url)

Get the geomark parts using the Get Geomark Parts REST API.

The parameters to the method are passed in using a Javascript object (map). See the Get Geomark Parts REST API for the list of supported parameters.

In addition the request must include the 'callback' parameter which must be a Javascript function. This function will be called with a single argument containing either a single geomark parts Javascript object or a Javascript object with the "items" property containing an array of geomark part Javascript objects if the geomark was found successfully. If there was an error this will be recorded in the Javascript error console.

The following code fragment shows an example of using the API.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://apps.gov.bc.ca/pub/geomark/js/geomark.js" ></script>>
<script type="text/javascript">
  function getGeomarkPartsExample() {
    var baseUrl = 'https://apps.gov.bc.ca/pub/geomark';
    var client = new GeomarkClient(baseUrl);
    client.getGeomarkParts({
      'geomarkId': 'gm-abcdefghijklmnopqrstuv0bcislands',
      'srid': 4326,
      'callback': function(geomarkParts) {
        if (geomarkParts.id) {
          alert('Found geomark: ' + geomarkParts.geometry);
        } else {
          alert('Found geomark: ' + geomarkParts.items[0].geometry);
        }
      }
    });
  }
</script>

Parameter Type Description
url string The url to the Geomark web service.

getGeomarkPoint(url)

Get the geomark point using the Get Geomark Point REST API.

The parameters to the method are passed in using a Javascript object (map). See the Get Geomark Point REST API for the list of supported parameters.

In addition the request must include the 'callback' parameter which must be a Javascript function. This function will be called with a single argument containing the geomark point Javascript object if the geomark was found successfully. If there was an error this will be recorded in the Javascript error console.

The following code fragment shows an example of using the API.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://apps.gov.bc.ca/pub/geomark/js/geomark.js" ></script>>
<script type="text/javascript">
  function getGeomarkPointExample() {
    var baseUrl = 'https://apps.gov.bc.ca/pub/geomark';
    var client = new GeomarkClient(baseUrl);
    client.getGeomarkPoint({
      'geomarkId': 'gm-abcdefghijklmnopqrstuv0bcislands',
      'srid': 4326,
      'callback': function(geomarkPoint) {
        alert('Found geomark: ' + geomarkPoint.geometry);
      }
    });
  }
</script>

Parameter Type Description
url string The url to the Geomark web service.