Properties:
Lmap
Returns the leaflet map object. After you access the leaflet map object, all the methods and properties of the leaflet library can be applied to it.
Returns:
Leaflet map: Returns leaflet map object.
Example:
const leafletMap = map.Lmap;
_boundsLayer
Returns the extent information drawn on the map.
Returns:
Object: Returns bounding box information.
Example:
const bBoxInfo= map._boundsLayer;
Methods:
addBaseLayer(baseMap, showAsDefault)
Adds base map to the map.
Parameters:
baseMap is an object contains base map information. Choices are: GL.BaseLayers.OSM | GL.BaseLayers.Google | GL.BaseLayers.Mapbox (GL is geobox-leaflet.js object).
showAsDefault is a boolean parameter. If true, this base map is used as the default base map.
Returns:
String: Returns a message that shows adding base map was successful or not. Null message means adding was successful.
Example:
const result = map.addBaseLayer(GL.BaseLayers.OSM, true);
zoomToBounds(latLngBounds, padding)
Zooms to the specified bounding box.
Parameters:
latLngBounds (Object): Leaflet latLngBounds object.
padding is a number to create space between the bounds and the map.
Returns:
String: Returns a message that shows zooming was successful or not. Null message means zooming was successful.
Example:
vat bounds = L.latLngBounds([35,51],[36,52]); const result = map.zoomToBounds(bounds, 5);
zoomToWorld()
Zooms to the whole world extent.
Example:
const result = map.zoomToWorld();
showSpinner()
Activates the spinner on the map. You can use this method before starting the time-consuming processes.
Example:
map.showSpinner();
hideSpinner()
Deactivates the spinner.
Example:
map.hideSpinner();
openDialog(options)
Opens a new window to display information. This window can contain any information. This window can be moved.
Parameters:
options (Object)
Name | Description |
---|---|
options.content
Any
|
content can be a message string or can be any HTML element. |
options.width
Number?
|
width of the dialog window in pixel. |
options.height
Number?
|
height of the dialog window in pixel. |
Returns:
Object: Returns dialog object.
Example:
const dialog = map.openDialog({content: 'Welcome to Geobox', width: 300, height: 100});
closeDialog()
Closes the existing dialog window.
Example:
map.closeDialog();
showMessage(message)
Opens a new window to display the desired message.
Parameters:
message is a string that you want to show.
Example:
map.showMessage('Welcome to Geobox');
startDrawingBounds()
Puts the map into draw mode so you can draw a bounding box.
Example:
map.startDrawingBounds();
After drawing the bounding box, you can access the coordinates of the drawn bounding box using _boundsLayer.
cancelDrawingBounds()
Deactivates draw mode.
Example:
map.cancelDrawingBounds();
displayBounds(latLngBounds)
Displays the bounding box on the map.
Parameters:
latLngBounds (Object): Leaflet latLngBounds object.
Example:
map.displayBounds({'_southWest': {'lat': 31,'lng': 52},'_northEast': {'lat': 34,'lng': 57}});
clearBounds()
Deletes the existing drawn bounding box on the map.
Example:
map.clearBounds();
addButton(options)
Adds a new button on the map. When it is clicked, the function defined for it will be executed.
Parameters:
options (Object)
Name | Description |
---|---|
options.name
String
|
Name of button. |
options.tooltip
String
|
Tooltip of button. |
options.color
String
|
Color of icon. Choices are: rgb color | rgba color | hex color. |
options.icon
String
|
Name of icon in google icons library. (Google icons library should be added to the project) |
options.click
Function
|
Function that triggers when the button is clicked. |
Returns:
Object: Returns button object.
Example:
Tip: The fLayer is described in the featureLayer construction section.
const zoomBtn = map.addButton({ name: 'zoom', tooltip: 'zoom to feature with id 100', color: 'red', icon: 'zoom_in', click: () => { fLayer.zoomTo(100); } })