-
class GeoAdmin.API(options)
| param options: | Object options |
| return: | GeoAdmin.API |
Create a GeoAdmin API instance.
An OpenLayers.ProxyHost is setup at the address /ogcproxy
Example Use
Sample code to create a map with the API:
var api = new GeoAdmin.API();
api.createMap({
div: "mymap1"
});
Config Options
Configuration properties.
-
activatePopup
Boolean
Define if the popups are activated for the vector layer, per default true
-
drawLayer
OpenLayers.Layer
DEPRECATED OpenLayers layer uses to present vector information (like Marker). Use this.map.vector instead.
-
lang
String
Lang of the API, can be ‘de’ (default), ‘it’, ‘fr’, ‘fi’ (for rumantsch) or ‘en’
-
map
OpenLayers.Map
A OpenLayers.Map instance
-
mapPanel
GeoAdmin.MapPanel
Panel containing the map
-
selectCtrl
OpenLayers.Control.SelectFeature
Select control associated to vector layer
Public Methods
Public methods.
-
API.createBaseLayerTool()
| Parameters: | options – Object options |
- Valid properties for the options argument:
- renderTo - Mixed: Specify the id of the element, a DOM element or an existing Element that this component will be rendered into.
- label - String: optional label on the left of the slider (representing the swissimage)
- slider - Object: optional object for setting slider options, like width
- combo - Object: optional object for setting combo options, like width
| Returns: | GeoAdmin.BaseLayerTool |
Create a base layer tool allowing the user to switch the background layer
api.createBaseLayerTool({
renderTo: "baselayertool",
label: "Orthophoto",
slider: {
width: 150
},
combo: {
width: 200
}
});
-
API.createBodSearchCombo()
| Parameters: | options – Object options. |
- Valid properties for the options argument:
- width - Integer : width of the combo box, per default 500
| Returns: | GeoAdmin.BodSearchComboBox |
api.createBodSearchCombo({
width: 500,
renderTo: 'mydiv'
});
Create a BOD (Betriebsobjektdatenbank) search combobox. It searches within the available layer.
-
API.createExtendedTooltip()
| Parameters: | options – Object Options to pass to the GeoAdmin.ExtendedTooltip constructor. |
| Returns: | GeoAdmin.ExtendedTooltip An OpenLayers.Control.GetFeature displaying feature tooltip after user click in the map. If box: true and handlerOptions: { box: { keyMask: Ext.isMac ? OpenLAyers.Handler.MOD_META : OpenLayers.Handler.MOD_CTRL } } passed in options, the interactive selection by rectangle is activated on key Ctrl + click. |
Example:
api.createExtendedTooltip({});
-
API.createKmlLayer()
| Parameters: |
- kmlUrl – String URL of the KML file. Set the OpenLayers.ProxyHost in order to use this function in your domain
- showPopup – Boolean Defines if a popup is shown
|
| Returns: | OpenLayers.Layer.Vector An OpenLayers.Layer.Vector containing the KML and placed in the map.
|
Create a KML layer
api.createKmlLayer("http://www.myurl.com/file.kml");
-
API.createLayerTree()
| Parameters: | options – Object options |
| Returns: | GeoAdmin.LayerTree |
Create a layer tree of layers associated to a map
-
API.createMap()
| Parameters: | options – Object options. |
- Valid properties for the options argument:
- div - String : name of the div in which the map will be placed
- layers - String or Array: optional list of layer name. Example: ‘ch.swisstopo.hiks-dufour,ch.swisstopo.gg25-gemeinde-flaeche.fill’ See layer list
- layers_opacity - String or Array: optional opacity information about the layer. Example: ‘0.2,0.7’
- layers_visibility - String or Array:optional boolean visibility information about the layer. Example: ‘false,true’
- bgLayer - String: optional name of background layer. It can be “ch.swisstopo.pixelkarte-farbe”, “ch.swisstopo.pixelkarte-grau” or “voidLayer”
- bgOpacity - Number:optional opacity for layer “ch.swisstopo.pixelkarte-farbe”, “ch.swisstopo.pixelkarte-grau” or “voidLayer” from 0 to 1
- easting - Number: optional CH1903 Y coordinate of the map center. Example: 600000
- northing - Number: optional CH1903 X coordinate of the map center. Example: 200000
- zoom - Number: optional zoom level. Possible values 0,1,2,3,4,5,6,7,8,9,10,11
Create an Openlayers.Map containing the GeoAdmin layer and configuration.
Example:
var api = new GeoAdmin.API();
api.createMap({
div: "mymap1"
});
-
API.createMapPanel()
| Parameters: | options – Object options. |
- Valid properties for the options argument:
- any GeoAdmin.MapPanel parameter
- mapOptions - Object containing options for the map, see createMap() options
| Returns: | GeoAdmin.MapPanel |
Create a map panel
Example:
api = new GeoAdmin.API();
api.createMapPanel({
height: 340,
renderTo: "mymappanel",
tbar: new Ext.Toolbar()
});
-
API.createNavigationHistory()
| Parameters: | options – Object options |
- Valid properties for the options argument:
- renderTo - Mixed: Specify the id of the element, a DOM element or an existing Element that this component will be rendered into.
| Returns: | GeoAdmin.NavigationHistory |
Create a set of previous/next buttons allowing the user to undo/redo navigation actions on the map
api.createNavigationHistory({
renderTo: "navigationhistory"
});
-
API.createPermalink()
| Parameters: | options – Object Options to pass to the GeoAdmin.Permalink constructor. |
| Returns: | GeoAdmin.Permalink An Ext.Action displaying the permalink when triggered. |
The returned action is typically included as a button in a toolbar.
Example:
api.createMapPanel({
tbar: [api.createPermalink()]
});
-
API.createPrint()
| Parameters: | options – Object options |
- Valid properties for the options argument:
- any Ext.Action option
- printBaseUrl - String containing the print service base URL. Optional, default value is “/print”. Please note that the domain must match the current page URL domain (a proxy may be required if using an external print service).
- printPanelOptions - Object containing any GeoExt.ux.SimplePrint option
- windowOptions - Object containing any Ext.Window option. Only used if printPanelOptions.renderTo is not available (an Ext.Window is then used to display the print form).
Create a printing button. Please note that this method implies the map is embedded in a GeoExt.MapPanel.
api.createPrint({
text: 'Print it!',
printPanelOptions: {
renderTo: 'print',
mapPanel: api.mapPanel
}
});
-
API.createSwissSearchCombo()
| Parameters: | options – Object options. |
- Valid properties for the options argument:
- width - Integer : width of the combo box, per default 300
| Returns: | GeoAdmin.SwissSearchComboBox |
Create a Swiss Search combobox
Example:
var api = new GeoAdmin.API();
api.createMap({
div: "mymap2",
easting: 600000,
northing: 200000,
zoom: 7
});
api.createSwissSearchCombo({
width: 500,
renderTo: "mysearch2",
ref: 'geoadmin'
});
-
API.createTooltip()
| Parameters: | options – Object Options to pass to the GeoAdmin.Tooltip constructor. |
| Returns: | GeoAdmin.Tooltip An OpenLayers.Control.GetFeature displaying feature tooltip after user click in the map. |
Example:
-
API.highlightFeatures()
| Parameters: |
- layer – String layer name
- ids – String or Array comma separated list of feature identifier
|
Example:
api.highlightFeatures('ch.swisstopo.gg25-gemeinde-flaeche.fill', 5922);
-
API.recenterFeatures()
| Parameters: |
- layer – String layer name
- ids – String or Array comma separated list of feature identifier
|
Recenter and highlight features in the map
Example:
api.showFeatures('ch.swisstopo.gg25-gemeinde-flaeche.fill', 5922);
-
API.setBgLayer()
| Parameters: |
- layername – String name of the layer: voidLayer,ch.swisstopo.swissimage,ch.swisstopo.pixelkarte-farbe or ch.swisstopo.pixelkarte-grau
- opacity – Float optional opacity of the layer between 0 and 1
|
Set the background layer with the corresponding opacity
-
API.showMarker()
| Parameters: | options – Object options |
- Valid properties for the options argument:
- renderTo - Mixed: Specify the id of the element, a DOM element or an existing Element that this component will be rendered into.
- easting - Number: optional CH1903 Y position of the marker, default: map center
- northing - Number: optional CH1903 X position of the marker, default: map center
- iconPath - String: optional path of a custom icon for the marker (url or relative), default: marker-gold.png (in repository GeoAdmin.ux/Map/img/)
- recenter - String: optional define if the map has to recentered at the marker position “true” or “false”, default: “false”
- graphicHeight - Number:optional height of the icon, default: the icon height
- graphicWidth - Number: optional width of the image, default: the icon width
- fillOpacity - Number: optional opacity of the marker (from 0 to 1), default: 1
- html - String`: optional html content of a popup, default: null
| Returns: | OpenLayers.Feature.Vector |
Show a marker in the map
Example:
var api = new GeoAdmin.API();
api.createMap({
div: "mymap6",
easting: 600000,
northing: 200000,
zoom: 8
});
api.showMarker();
-
API.showMousePosition()
| Parameters: | options – Object options |
- Valid properties for the options arguments are those of the OpenLayers.Control.MousePosition:
- prefix - String: optional text befor the mouse position, default: Coordinates (m)
- separator - String: optional separator between northing and easting, default: ”, “
- suffix - String: optional text after the mouse coordinates, default: empty
- numDigits - Integer: optional, number of digits to display, default 0
- granularity - Integer: optional, minimal distance in pixels before refreshing mouse position , default: 10
- emptyString - String: optional, value to display when the mouse is outside the map, default null
- displayProjection - OpenLayers.Projection: optional, the projection in which the mouse is diplayed. Default is same as the map (EPSG:21781).
Add a control displaying the current mouse position in the map. This function is based on OpenLayers.Control.MousePosition and provides more configuration capabilities compared to GeoAdmin.MousePosition UX.
| Parameters: | options – Object options |
- Valid properties for the options argument:
- renderTo - Mixed: Specify the id of the element, a DOM element or an existing Element that this component will be rendered into.
- easting - Number: optional CH1903 Y position of the marker, default: map center
- northing - Number: optional CH1903 X position of the marker, default: map center
- recenter - String: optional define if the map has to recentered at the marker position “true” or “false”, default: “false”
- title - String: optional, title of the window, default: “”
- html - String: optional, html content of the popup, default: null . If empty, no popup is shown
- width - Integer: optional, width of the popup, default: 200
- feature - OpenLayers.Feature: optional feature associated with the popup
- collapsible - Boolean: optional, default false
- unpinnable - Boolean: optional, default true
- panIn - Boolean: optional, The popup should pan the map so that the popup is fully in view when it is rendered. Default is true.
Show a popup in the map
Example:
var api = new GeoAdmin.API();
api.createMap({
div: "mymap6",
easting: 600000,
northing: 200000,
zoom: 8
});
api.showPopup({
html: "My nice popup !",
title: "Title of my nice popup"
});