\CustMaps
Custom users maps class
Synopsis
class CustMaps
{
- // constants
- const URL_ME = '?module=custmaps';
- const TABLE_MAPS = 'custmaps';
- const TABLE_ITEMS = 'custmapsitems';
- const TABLE_LINES = 'custmaps_lines';
- const EX_NO_MAP_ID = 'NOT_EXISTING_MAP_ID';
- const EX_NO_ITM_ID = 'NOT_EXISTING_ITEM_ID';
- const EX_NO_LINE_ID = 'NOT_EXISTING_LINE_ID';
- const LINE_DEFAULT_COLOR = '#f57601';
- const LINE_DEFAULT_FIBERS_AMOUNT = 0;
- const LINE_DEFAULT_WIDTH = 2;
- const LINE_EDITOR_LIB = 'modules/jsc/custmaps/line-editor.js';
- const MARKERS_TOGGLE_LIB = 'modules/jsc/custmaps/markers-toggle.js';
- const KML_IMPORT_TMP_PATH = 'exports/';
- const ROUTE_SHOWMAP = 'showmap';
- const ROUTE_DELETEMAP = 'deletemap';
- const ROUTE_SHOWITEMS = 'showitems';
- const ROUTE_SHOWLINES = 'showlines';
- const ROUTE_DELETEITEM = 'deleteitem';
- const ROUTE_EDITITEM = 'edititem';
- const ROUTE_MODIFYLINE = 'modifyline';
- const ROUTE_EDITLINE = 'editline';
- const ROUTE_DELETELINE = 'deleteline';
- const ROUTE_MARKEREDIT = 'markersedit';
- const ROUTE_LINEEDIT = 'lineedit';
- const ROUTE_CL = 'cl';
- const ROUTE_MAPLIST = 'maplist';
- const ROUTE_MAPCONFIG = 'mapconfig';
- const ROUTE_KMLIMPORT = 'kmlimport';
- const ROUTE_KMLIMPORT_OK = 'kmlimport_ok';
- const ROUTE_KMLEXPORT = 'kmlexport';
- const PROUTE_NEWMAPNAME = 'newmapname';
- const PROUTE_EDITMAPID = 'editmapid';
- const PROUTE_EDITMAPNAME = 'editmapname';
- const PROUTE_NEWMAP_CLUSTERING = 'newmap_clustering';
- const PROUTE_NEWMAP_CMARKERS = 'newmap_cmarkers';
- const PROUTE_NEWMAP_METRICS = 'newmap_metrics';
- const PROUTE_EDITMAP_CLUSTERING = 'editmap_clustering';
- const PROUTE_EDITMAP_CMARKERS = 'editmap_cmarkers';
- const PROUTE_EDITMAP_METRICS = 'editmap_metrics';
- const PROUTE_NEWITEMGEO = 'newitemgeo';
- const PROUTE_NEWITEMTYPE = 'newitemtype';
- const PROUTE_NEWITEMNAME = 'newitemname';
- const PROUTE_NEWITEMLOCATION = 'newitemlocation';
- const PROUTE_NEWLINE_MAPID = 'newline_mapid';
- const PROUTE_NEWLINE_LINEID = 'newline_lineid';
- const PROUTE_NEWLINE_STYLE_WIDTH = 'newline_style_width';
- const PROUTE_NEWLINE_STYLE_COLOR = 'newline_style_color';
- const PROUTE_NEWLINE_GEO = 'newline_geo';
- const PROUTE_NEWLINE_NAME = 'newline_name';
- const PROUTE_NEWLINE_FIBERS_AMOUNT = 'newline_fibers_amount';
- const PROUTE_NEWLINE_LENGTH_M = 'newline_length_m';
- const PROUTE_NEWLINE_DESCRIPTION = 'newline_description';
- const PROUTE_EDITITEMID = 'edititemid';
- const PROUTE_EDITITEMTYPE = 'edititemtype';
- const PROUTE_EDITITEMGEO = 'edititemgeo';
- const PROUTE_EDITITEMNAME = 'edititemname';
- const PROUTE_EDITITEMLOCATION = 'edititemlocation';
- const PROUTE_EDITLINEID = 'editlineid';
- const PROUTE_EDITLINE_NAME = 'editline_name';
- const PROUTE_EDITLINE_FIBERS_AMOUNT = 'editline_fibers_amount';
- const PROUTE_EDITLINE_LENGTH_M = 'editline_length_m';
- const PROUTE_EDITLINE_STYLE_COLOR = 'editline_style_color';
- const PROUTE_EDITLINE_STYLE_WIDTH = 'editline_style_width';
- const PROUTE_EDITLINE_DESCRIPTION = 'editline_description';
- const PROUTE_EDITLINE_GEO = 'editline_geo';
- const PROUTE_KMLIMPORT = 'kmlimport';
- const PROUTE_KMLIMPORT_FILE = 'custmaps_kml_upload';
- const PROUTE_KMLIMPORT_ITEMTYPE = 'kmlimport_itemtype';
- // members
- protected array $allMaps = ;
- protected array $allItems = ;
- protected array $ymapsCfg = ;
- protected array $altCfg = ;
- protected array $itemTypes = ;
- protected string $center = '';
- protected string $zoom = '';
- protected $mapCore = NULL;
- protected $mapsDb = NULL;
- protected $itemsDb = NULL;
- protected $linesDb = NULL;
- protected integer $showMapId = 0;
- protected array $allLines = ;
- protected $messages = NULL;
- protected array $clustringOptions = ;
- // methods
- public void __construct()
- public static string urlMapList()
- public static string urlMapConfig()
- public static string urlKmlImport()
- public static string urlMapKmlExport()
- protected void initMessages()
- protected void initDb()
- protected void setShowMapId()
- protected void initMapCore()
- protected void loadYmapsConfig()
- protected void loadAlterConfig()
- protected void loadMaps()
- protected void setDefaults()
- protected void setItemTypes()
- protected string itemGetIcon()
- protected string itemGetTypeName()
- protected string renderAttachmentsCell()
- protected void loadItems()
- protected void loadLines()
- protected string filterLayers()
- protected string mapControls()
- protected string mapLayersControls()
- public string renderMapList()
- public string itemEditForm()
- public string renderMarkerEdit()
- public void itemEdit()
- public string renderItemsList()
- public int itemDelete()
- protected string mapCreateForm()
- protected string mapKmlImportForm()
- public string renderKmlImportPage()
- protected string mapEditForm()
- protected string renderMapStats()
- public string renderMapConfigPage()
- protected string mapListControls()
- public void mapCreate()
- public array mapImportFromKml()
- public string renderKmlImportResult()
- public string mapExportToKml()
- public void mapExportKmlSend()
- protected string mapExportKmlFileName()
- protected float lineCalcLengthMeters()
- protected string sanitizeImportText()
- protected string truncateImportField()
- public void mapDelete()
- public void mapEdit()
- public string mapGetName()
- public string mapGetPlacemarks()
- protected array lineParsePoints()
- protected string lineGetMiniMapCenterFromPoints()
- protected string lineGetRandomColor()
- protected array lineGetWidthOptions()
- public string mapGetLines()
- protected string lineQuickEditForm()
- public string renderLineEdit()
- public string lineEditForm()
- public string renderLinesList()
- public void lineCreate()
- public void lineEdit()
- public int lineDelete()
- public array lineGetById()
- public array lineGetAllByMap()
- protected string itemLocationForm()
- public void itemCreate()
- public string mapInit()
- protected void registerCustmapMarkersToggleControl()
- public string mapLocationEditor()
- protected array lineGetFibersAmountOptions()
- protected string lineLocationForm()
- public string mapLineEditor()
Constants
| Name | Value |
|---|---|
| URL_ME | '?module=custmaps' |
| TABLE_MAPS | 'custmaps' |
| TABLE_ITEMS | 'custmapsitems' |
| TABLE_LINES | 'custmaps_lines' |
| EX_NO_MAP_ID | 'NOT_EXISTING_MAP_ID' |
| EX_NO_ITM_ID | 'NOT_EXISTING_ITEM_ID' |
| EX_NO_LINE_ID | 'NOT_EXISTING_LINE_ID' |
| LINE_DEFAULT_COLOR | '#f57601' |
| LINE_DEFAULT_FIBERS_AMOUNT | 0 |
| LINE_DEFAULT_WIDTH | 2 |
| LINE_EDITOR_LIB | 'modules/jsc/custmaps/line-editor.js' |
| MARKERS_TOGGLE_LIB | 'modules/jsc/custmaps/markers-toggle.js' |
| KML_IMPORT_TMP_PATH | 'exports/' |
| ROUTE_SHOWMAP | 'showmap' |
| ROUTE_DELETEMAP | 'deletemap' |
| ROUTE_SHOWITEMS | 'showitems' |
| ROUTE_SHOWLINES | 'showlines' |
| ROUTE_DELETEITEM | 'deleteitem' |
| ROUTE_EDITITEM | 'edititem' |
| ROUTE_MODIFYLINE | 'modifyline' |
| ROUTE_EDITLINE | 'editline' |
| ROUTE_DELETELINE | 'deleteline' |
| ROUTE_MARKEREDIT | 'markersedit' |
| ROUTE_LINEEDIT | 'lineedit' |
| ROUTE_CL | 'cl' |
| ROUTE_MAPLIST | 'maplist' |
| ROUTE_MAPCONFIG | 'mapconfig' |
| ROUTE_KMLIMPORT | 'kmlimport' |
| ROUTE_KMLIMPORT_OK | 'kmlimport_ok' |
| ROUTE_KMLEXPORT | 'kmlexport' |
| PROUTE_NEWMAPNAME | 'newmapname' |
| PROUTE_EDITMAPID | 'editmapid' |
| PROUTE_EDITMAPNAME | 'editmapname' |
| PROUTE_NEWMAP_CLUSTERING | 'newmap_clustering' |
| PROUTE_NEWMAP_CMARKERS | 'newmap_cmarkers' |
| PROUTE_NEWMAP_METRICS | 'newmap_metrics' |
| PROUTE_EDITMAP_CLUSTERING | 'editmap_clustering' |
| PROUTE_EDITMAP_CMARKERS | 'editmap_cmarkers' |
| PROUTE_EDITMAP_METRICS | 'editmap_metrics' |
| PROUTE_NEWITEMGEO | 'newitemgeo' |
| PROUTE_NEWITEMTYPE | 'newitemtype' |
| PROUTE_NEWITEMNAME | 'newitemname' |
| PROUTE_NEWITEMLOCATION | 'newitemlocation' |
| PROUTE_NEWLINE_MAPID | 'newline_mapid' |
| PROUTE_NEWLINE_LINEID | 'newline_lineid' |
| PROUTE_NEWLINE_STYLE_WIDTH | 'newline_style_width' |
| PROUTE_NEWLINE_STYLE_COLOR | 'newline_style_color' |
| PROUTE_NEWLINE_GEO | 'newline_geo' |
| PROUTE_NEWLINE_NAME | 'newline_name' |
| PROUTE_NEWLINE_FIBERS_AMOUNT | 'newline_fibers_amount' |
| PROUTE_NEWLINE_LENGTH_M | 'newline_length_m' |
| PROUTE_NEWLINE_DESCRIPTION | 'newline_description' |
| PROUTE_EDITITEMID | 'edititemid' |
| PROUTE_EDITITEMTYPE | 'edititemtype' |
| PROUTE_EDITITEMGEO | 'edititemgeo' |
| PROUTE_EDITITEMNAME | 'edititemname' |
| PROUTE_EDITITEMLOCATION | 'edititemlocation' |
| PROUTE_EDITLINEID | 'editlineid' |
| PROUTE_EDITLINE_NAME | 'editline_name' |
| PROUTE_EDITLINE_FIBERS_AMOUNT | 'editline_fibers_amount' |
| PROUTE_EDITLINE_LENGTH_M | 'editline_length_m' |
| PROUTE_EDITLINE_STYLE_COLOR | 'editline_style_color' |
| PROUTE_EDITLINE_STYLE_WIDTH | 'editline_style_width' |
| PROUTE_EDITLINE_DESCRIPTION | 'editline_description' |
| PROUTE_EDITLINE_GEO | 'editline_geo' |
| PROUTE_KMLIMPORT | 'kmlimport' |
| PROUTE_KMLIMPORT_FILE | 'custmaps_kml_upload' |
| PROUTE_KMLIMPORT_ITEMTYPE | 'kmlimport_itemtype' |
Members
protected
- $allItems
—
array
Contains all existing items as id=>itemData - $allLines
—
array
Contains all existing lines as id=>lineData - $allMaps
—
array
Contains all existing maps as id=>mapData - $altCfg
—
array
Contains system alter configuration as key=>value - $center
—
string
Current map center - $clustringOptions
—
array
Default clustering options. - $itemTypes
—
array
Contains available item types as type=>name - $itemsDb
—
Database abstraction layer for items aka markers - $linesDb
—
Database abstraction layer for lines - $mapCore
—
Map core instance - $mapsDb
—
Database abstraction layer for maps - $messages
—
System message helper object placeholder - $showMapId
—
int
ID of the map which is currently being shown - $ymapsCfg
—
array
Contains Ymaps configuration as key=>value - $zoom
—
int
Current map zoom
Methods
protected
- filterLayers() — Filters some layer from current
- initDb() — Initializes database abstraction layers
- initMapCore() — Initializes shared map core instance
- initMessages() — Initializes system message helper
- itemGetIcon() — Returns icon for some item type
- itemGetTypeName() — Returns item type localized name
- itemLocationForm() — Returns item location form
- lineCalcLengthMeters() — Calculates polyline length in meters using haversine formula
- lineGetFibersAmountOptions() — Returns fibers amount options for line editor
- lineGetMiniMapCenterFromPoints() — Returns map center for a polyline minimap: one existing vertex between ends (middle index along the polyline), or empty if there are no valid points.
- lineGetRandomColor() — Returns random line color
- lineGetWidthOptions() — Returns line width selector options
- lineLocationForm() — Returns line location form for map editor
- lineParsePoints() — Parses line geometry to MapCore-compatible points array
- lineQuickEditForm() — Quick line edit form (name, style, fibers, description) without geometry editor.
- loadAlterConfig() — Loads system-wide alter config into private config storage
- loadItems() — Loads all existing custom maps items into private data property
- loadLines() — Loads all existing custom maps lines into private data property
- loadMaps() — Loads existing custom maps into private data property
- loadYmapsConfig() — Loads system-wide ymaps config into private config storage
- mapControls() — Returns map controls
- mapCreateForm() — Returns map creation form
- mapEditForm() — Returns custom map editing form
- mapExportKmlFileName() — Returns safe download filename for map KML export
- mapKmlImportForm() — Returns KML import upload form
- mapLayersControls() — Returns custom map layers selection controls rendered under the map
- mapListControls() — Returns map list controls panel
- registerCustmapMarkersToggleControl() — Adds a map control to show/hide marker layers and persists choice in localStorage.
- renderAttachmentsCell() — Renders attachments indicators with hidden sort key for datatables
- renderMapStats() — Renders basic map statistics like lines and markers count, length, etc.
- sanitizeImportText() — Sanitizes imported text: strip_tags then ubRouting safe filter
- setDefaults() — Sets default map center and zoom
- setItemTypes() — Sets available item types into private data property
- setShowMapId() — Sets ID of the map which is currently being shown
- truncateImportField() — Truncates import field value to max length
public
- __construct()
- itemCreate() — Creates new map item in database
- itemDelete() — Deletes item from database by its ID
- itemEdit() — Changes existing item properties in database
- itemEditForm() — Returns item edit form
- lineCreate() — Creates new map line in database
- lineDelete() — Deletes line by id
- lineEdit() — Changes existing line in database
- lineEditForm() — Returns line edit form
- lineGetAllByMap() — Returns all lines for selected map
- lineGetById() — Returns line by id
- mapCreate() — Creates new custom map in database
- mapDelete() — Deletes existing custom map by its ID
- mapEdit() — Changes existing custom map name in database
- mapExportKmlSend() — Sends map KML export as file download
- mapExportToKml() — Builds KML document string for map objects
- mapGetLines() — Returns list of map polylines
- mapGetName() — Returns existing custom map name by its Id
- mapGetPlacemarks() — Returns list of map placemarks
- mapImportFromKml() — Imports KML/KMZ file into a new custom map
- mapInit() — Returns initialized JS map
- mapLineEditor() — Adds line editor on map for Leaflet.Editable-based polyline creation and editing
- mapLocationEditor() — Return geo coordinates locator with embedded form
- renderItemsList() — Returns existing map markers list as embedded datatable
- renderKmlImportPage() — Renders KML import page with upload form
- renderKmlImportResult() — Renders KML import result summary
- renderLineEdit() — Renders line profile/quick editing form
- renderLinesList() — Renders existing map lines list as embedded datatable
- renderMapConfigPage() — Map settings page: back link and edit form
- renderMapList() — Returns existing maps list view
- renderMarkerEdit() — Renders marker edit UI: edit form and minimap side by side in a flex row (when geo is set),
- urlKmlImport() — URL of the KML import screen
- urlMapConfig() — URL of the map configuration screen (name, clustering, etc.)
- urlMapKmlExport() — URL of the KML export download for map
- urlMapList() — URL of the custom maps list screen (module root)