\MapCore
MapCore API implementation
Synopsis
class MapCore
{
- // members
- protected string $center = '';
- protected integer $zoom = 15;
- protected string $type = 'roadmap';
- protected string $container = 'ubmap';
- protected string $searchPrefill = '';
- protected string $placemarks = '';
- protected string $extraCode = '';
- protected array $extraScriptSrcs = ;
- protected array $mapsCfg = ;
- protected array $usedIcons = ;
- protected bool $clusteringEnabled = false;
- protected array $clusterOptions = ;
- protected bool $forceCanvasMarkers = false;
- protected bool $rememberZoom = false;
- protected bool $rememberPosition = false;
- protected bool $rememberLayer = false;
- protected bool $markerToggleShellEnabled = false;
- protected bool $fpsMeterEnabled = false;
- protected integer $fpsMeterInterval = 1000;
- protected string $fpsMeterPosition = 'bottomleft';
- protected array $objectCounts = ;
- protected static array $icons = ;
- protected string $additionalAttributions = '';
- protected string $tileLayer = '';
- protected string $tileLayerCustoms = '';
- protected bool $canvasRender = false;
- // methods
- public void __construct()
- protected void loadConfigOptions()
- protected void preprocessTileLayerOpts()
- public void setContainerName()
- public string renderContainer()
- public setCenter()
- public setZoom()
- public setRememberZoom()
- public setRememberPosition()
- public setRememberLayer()
- public setMarkerToggleShellEnabled()
- public string getContainerId()
- public setType()
- public setSearchPrefill()
- public addRawJs()
- public addScriptSrc()
- public array getMapObjects()
- public array getObjectCounts()
- public injectMapObjects()
- public string getPlacemarks()
- public injectPlacemarks()
- public setClustering()
- public setForceCanvasMarkers()
- public setFpsMeter()
- public addLocationEditor()
- public registerIcon()
- public addMarker()
- public addDynamicMarker()
- public addCircle()
- public addLine()
- public addPolyline()
- public addPolygon()
- public addRectangle()
- public addCircleMarker()
- public addGeoJSON()
- public string render()
- protected string quoteJs()
- protected string buildLatLngArrayJs()
- protected string buildMarkerJs()
- public static array getIconKeys()
- public static string resolveIconPath()
- public static string normalizeIconKey()
- public static bool registerIconDefinition()
Members
protected
- $additionalAttributions
—
string
Additional attributions for map - $canvasRender
—
bool
Enables canvas rendering for vector layers (Leaflet preferCanvas) - $center
—
string
Map center in "lat,lng" format, empty means geolocation - $clusterOptions
—
array
Marker cluster options - $clusteringEnabled
—
bool
Enables marker clustering - $container
—
string
Map container id - $extraCode
—
string
Additional JS snippets, editor etc. - $extraScriptSrcs
—
array
External JS files to load before the main map inline script (relative URLs) - $forceCanvasMarkers
—
bool
Forces placemark markers rendering via leaflet-markers-canvas - $fpsMeterEnabled
—
bool
Enables FPS meter overlay control - $fpsMeterInterval
—
int
FPS meter refresh interval in milliseconds - $fpsMeterPosition
—
string
FPS meter control position - $icons
—
array
Canonical icon key => image path - $mapsCfg
—
array
Maps configuration cache - $markerToggleShellEnabled
—
bool
When true, all marker attachments go inside a L.layerGroup on the map so callers can show/hide markers by adding/removing that group. - $objectCounts
—
array
Per-category counters of objects added via public add* methods. - $placemarks
—
string
JS snippets with map objects - $rememberLayer
—
bool
Remember last used layer - $rememberPosition
—
bool
Remember map center position - $rememberZoom
—
bool
Remember zoom level - $searchPrefill
—
string
Search box prefill text - $tileLayer
—
string
Custom Leaflet tile layer URL template, empty means default OSM - $tileLayerCustoms
—
string
Raw JS options appended to base L.tileLayer (subdomains, tms, etc.) - $type
—
string
Base layer type: roadmap, satellite, hybrid, terrain - $usedIcons
—
array
Marker icon cache for rendered JS - $zoom
—
int
Map zoom level
Methods
protected
- buildLatLngArrayJs() — Builds JS LatLng array literal from array of "lat,lng" strings
- buildMarkerJs() — Builds marker JS with icon cache support
- loadConfigOptions() — Loads ymaps.ini options into object properties
- preprocessTileLayerOpts() — Preprocesses tile layer options from maps config: custom tile URL, Leaflet options, attributions
- quoteJs() — Quotes string for JS using JSON encoding
public
- __construct() — Creates map builder instance
- addCircle() — Adds map circle
- addCircleMarker() — Adds circle marker (a circle with fixed pixel radius that does not scale with zoom)
- addDynamicMarker() — Adds marker with lazy AJAX popup loading
- addGeoJSON() — Adds GeoJSON layer to map
- addLine() — Adds line between two points
- addLocationEditor() — Adds location editor with coordinates picker and custom HTML form
- addMarker() — Adds marker to map
- addPolygon() — Adds polygon (closed multipoint shape) to map
- addPolyline() — Adds polyline (open multipoint line) to map
- addRawJs() — Appends raw JS snippet to map init code
- addRectangle() — Adds rectangle to map. Rectangle is defined by two opposite corners (south-west and north-east)
- addScriptSrc() — Registers an extra script URL to include before the main map script (deduplicated)
- getContainerId() — Returns map container DOM id used by Leaflet
- getIconKeys() — Returns list of canonical icon keys currently registered
- getMapObjects() — Returns raw map overlays payload (markers, shapes and extra JS)
- getObjectCounts() — Returns per-category counters of objects added via public add* methods
- getPlacemarks() — Returns only map placemarks JS buffer
- injectMapObjects() — Injects map overlays payload exported by getMapObjects()
- injectPlacemarks() — Injects raw map placemarks JS into map object
- normalizeIconKey() — Normalizes icon key
- registerIcon() — Registers custom icon in global map icon registry
- registerIconDefinition() — Registers or overrides icon path by key
- render() — Renders full map HTML and JS
- renderContainer() — Creates map container markup
- resolveIconPath() — Resolves icon key to icon image path
- setCenter() — Sets map center
- setClustering() — Enables or disables markers clustering
- setContainerName() — Sets container/instance name
- setForceCanvasMarkers() — Forces placemark markers rendering via canvas markers layer
- setFpsMeter() — Enables or disables FPS meter control on map
- setMarkerToggleShellEnabled() — When enabled, markers (cluster/canvas/plain) are parented under one L.layerGroup exposed as ubMarkerToggleShell in the rendered map script.
- setRememberLayer() — Enables or disables saving/restoring last used base layer via localStorage
- setRememberPosition() — Enables or disables saving/restoring map center via localStorage
- setRememberZoom() — Enables or disables saving/restoring map zoom via localStorage
- setSearchPrefill() — Sets geocoder search prefill
- setType() — Sets initial base layer type
- setZoom() — Sets map zoom