A method for implementing programmable layers of web-based maps
By creating multi-source layer templates and dynamic programming layer instances, flexible adaptation and complex business logic support for web-side map layer management are achieved, and the problem of insufficient static and adaptability of layer management in the existing technology is solved. , reduce maintenance costs.
Patent Information
- Application Number
- CN202210492065.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-07
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2042-05-07
AI Technical Summary
The existing web-end map layer management technology mainly relies on static JavaScript and Html, and cannot dynamically adapt to data source type changes and business logic expansion, and lacks flexibility and adaptability.
By creating and storing multi-source layer templates, generating dynamic programming layer instances, and using layer tree objects for real-time editing and management, real-time editing and execution of interfaces for attributes and interactive logic in the layer, supporting multi-source data types and Complex business logic.
It realizes flexible adaptability of layer management, reduces maintenance costs, supports multi-source data types and complex business logic, and improves the flexibility and adaptability of layer management.
Smart Images

Figure CN114860224B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a multi-source layer management technology in the field of Web-side maps, and in particular to a method for implementing a programmable layer of a Web-side map. Background Art
[0002] Layer management is an important basic module for Web-based map visualization. With the continuous development of Web-based map-related technologies and the increase in application needs, the layer management module with high efficiency, compatibility, and scalability has become an indispensable component of Web-based geographic spatial visualization capabilities.
[0003] The layer management in the industry is mainly implemented around static JavaScript+Html and configuration files, which only have the ability to control the visibility of layers. Once the data source type changes or the actual application requirements change, the layer management tool needs to be recoded for adaptation, and it does not have the ability to dynamically bind business logic. In response to the above problems, the present invention proposes a method for implementing programmable layers on a Web-side map. This method supports users to customize the design of multi-source layer templates containing layer configuration parameters and interactive event execution codes through an interface, and programs the template data based on the template to achieve the transformation of the layer management code layer from static files to dynamic programming template data, so that the attributes and interactive logic in the layer can be edited and executed in real time through the interface, thereby achieving the ability of layer management to flexibly adapt to various complex business logics. This method converts the implementation layer of layer management from static files to dynamically editable template data, meets the application end's requirements for supporting multi-source data types and complex business logic layer management, and reduces the maintenance cost of layer management. Summary of the invention
[0004] Purpose of the invention: The purpose of the present invention is to enable real-time editing of templates and layer parameters through a layer tree, modify the layer tree structure through interactive operations, and utilize layer information association strategies to implement the binding and execution of various hook functions in the layer template when layer management needs to support dynamic changes in data sources and expansion of business logic, thereby enabling the layer tree to support layer management requirements for multiple source data types and complex business logic.
[0005] In view of the shortcomings of the prior art, the present invention provides a method for implementing a programmable layer of a Web-side map, comprising the following steps:
[0006] Step 1, create and store a multi-source layer template;
[0007] Step 2: Create a programming layer instance and implement the interaction between the programming layer and the Web page;
[0008] Step 3, create a layer tree object and associate and organize the programming layer instance associations.
[0009] Step 1 includes:
[0010] Step 1-1, create a multi-source layer template: a multi-source layer template is a template used to create a programming layer instance; creating a multi-source layer template is used to configure the parameters of the multi-source layer template and various interactive functions; the parameter configuration of the multi-source layer template includes: template name, mutually exclusive identifiers of the same type, and configuration of node display scenes; the interactive function configuration of the multi-source layer template includes: initialization hook function, check hook function, uncheck hook function, add to map hook function, and remove hook function configuration;
[0011] According to the parameters of the multi-source layer template and the interactive function configuration, the unique identifier LayerName of the multi-source layer template is generated, and finally a complete multi-source data template is formed;
[0012] Step 1-2, store multi-source layer templates: The multi-source layer templates are saved in the server database. Before saving, first traverse the multi-source layer templates stored in the server database, and check whether the same multi-source layer template already exists in the server database through the unique identifier LayerName match. If it exists, it will be overwritten or canceled according to the user's choice. If it does not exist, the storage operation is performed. The storage method is: convert the parameters of the multi-source layer template configured in step 1-1 and various interactive functions into strings using the browser's default method, and then send them to the server to import into the database for storage.
[0013] Step 2 includes:
[0014] Step 2-1, create a programming layer instance: the programming layer instance is created according to the multi-source layer template. According to the type of programming layer instance to be created, the corresponding multi-source layer template is queried from the server database, and the programming layer instance is created according to the parameters configured in the multi-source layer template. The unique identifier LayerName of the programming layer instance is set to bind with the unique identifier of the multi-source layer template to complete the creation of the programming layer instance;
[0015] Step 2-2, obtain the interactive function: obtain the multi-source layer template bound to it through the unique identifier LayerName of the programming layer instance, and obtain the interactive function configured on the multi-source layer template. At this time, the interactive function obtained is still in the form of a string, not an executable code;
[0016] Step 2-3, executable code conversion, convert the interactive function in string form into an executable interactive function in function form through the eval method, assign the converted interactive function to the hook function corresponding to the programming layer instance, and use the input parameters in the programming layer instance as the function input parameters;
[0017] Step 2-4, bind the hook function converted in step 2-2 to the interactive response event of the Web page to realize the interactive response between the programming layer hook function and the Web page.
[0018] Step 3 includes:
[0019] Step 3-1, create a layer tree object: The layer tree object is a tree structure, which is used to organize and manage the programming layer instances loaded and displayed on the web map. The hierarchical structure of the layer tree object is from low to high: programming layer instance, layer group object, layer tree object. The programming layer instance is the leaf node of the layer tree object; one or more programming layer instances that are managed in a unified manner constitute a layer group object, and the layer group objects constitute the layer tree object;
[0020] Step 3-2, the layer tree object is associated with the Web page, and the user operates the layer tree object by operating the Web page. On the Web page, a tree-like Dom node is constructed according to the content and hierarchy of the layer tree object, and the interactive events are bound to form a layer tree management interface. When the user operates the layer tree management interface, the layer tree object is processed accordingly in the bound interactive events;
[0021] Step 3-3, the layer tree object is associated with the programming layer instance: when a new programming layer instance is added, the instance should be added to the layer tree object as a leaf node; when a programming layer instance is deleted, the corresponding node should be deleted from the layer tree at the same time; when the leaf nodes on the layer tree are added, deleted, or the order is adjusted, the programming layer instances should be added, deleted, or the order should be adjusted accordingly on the web map.
[0022] In view of the problem that the current layer management in the industry is mainly implemented around static JavaScript+Html and configuration files, and is not capable of adapting to changes in data source types or changes in actual application requirements, the present invention proposes a method for implementing programmable layers on a Web-side map. This technology extracts various interactive event execution codes and layer configuration parameters of the layer from static files and configuration files, moves them to dynamic programming layer template data and stores them on a server. Users use the layer management interactive interface to edit the execution codes and configuration parameters of various types of layers in real time, so as to achieve the effect of customized design of layer templates containing layer configuration parameters and interactive event execution codes. Based on the template, the programming layer object is instantiated, and the function string in the programming template is converted into code and executed, so that the attributes and interactive logic in the layer can be edited and executed in real time through the interface, thereby realizing the ability of layer management to flexibly adapt to various complex business logics.
[0023] Beneficial effects: Compared with the prior art, the present invention proposes a programming layer technology for converting a code layer from a static file into a programmable instance. The method is based on the programmable layer, extracts the execution code of various interactive events of the layer and the configuration parameters of the layer from the static file and the configuration file, moves them to the dynamic programming layer template data and stores them by the server. Coders can edit the execution code and configuration parameters of various types of layers in real time on the Web client. The present invention has the advantages of low layer management and maintenance cost, dynamic adaptation to any type of data source and complex business logic, and easy expansion of layer types. It has important prospects in Web-side map-related systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more clear.
[0025] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION
[0026] The following is a specific description in conjunction with the implementation of the present invention:
[0027] A method for constructing a multi-source layer management system based on programming layers is established according to the following steps: The complete working method flow is as follows: Figure 1 As shown, the so-called multi-source layer management organizes and manages various types of layers and business function modules according to needs based on certain business logic, and builds a tree-like management interface based on actual applications. The hook function corresponding to the layer template is called through the interactive events of the layer tree nodes in the layer management interface, and the business functions are bound and controlled with the nodes in the tree.
[0028] A. Input multi-source layer template parameters through the interface, build a programming layer instance, send a request to the server to obtain multi-source layer template data, programming layer attribute data, and layer tree structure data in the database, use internal functions to convert the above three types of data from string type data to arrays or objects, traverse the multi-source layer template array, and obtain each multi-source layer template in the array for processing: obtain the default hook function attributes of the multi-source layer template data, convert the string type hook function attributes to the executable function type, overwrite the original attributes, and complete all template hook function type conversions in sequence.
[0029] B. Create and initialize a programming layer instance and associate it with a layer tree. Traverse the programming layer attribute data and layer tree structure data obtained from A, obtain the layerType attribute in the programming layer instance attribute data, match the multi-source layer template corresponding to the programming layer instance according to the layerType attribute, use the layer attribute data obtained through step A as a parameter, create a programming layer instance through the multi-source layer template, use the layer tree structure data to create a layer tree instance, call the layer tree built-in method to obtain the node object array in the layer tree, each tree node object corresponds to a programming layer instance, the node ID is used as the unique identifier of the node, and has the ability to match the programming layer instance. After the layer tree node is matched with the programming layer instance ID through the node unique identifier ID, it is associated with the programming layer instance.
[0030] C. Obtain the custom parameters of the layer template through the interactive interface: template name, template English name, mutually exclusive mark of the same type, layer display scene (2D / 3D), user-defined configuration parameter set, initialization hook function, checked hook function, unchecked hook function, add to map hook function, remove hook function, and conduct a comprehensive check on the above parameters. If it is found that the parameter format or data does not meet the standards, there is no prompt to re-enter.
[0031] D. Create a user-defined multi-source layer template, verify the multi-source layer template name, multi-source layer template English name, whether the same type is mutually exclusive, layer display scene (2D / 3D), user-defined configuration parameter set, initialization hook function, checked hook function, unchecked hook function, add to map hook function, remove hook function parameters, traverse the current global multi-source layer template array according to the template English name to ensure the uniqueness of the multi-source layer template name, use the multi-source layer template parameters to create a new multi-source layer template object of type template English name, and add it to the global multi-source layer array after creation.
[0032] E. Serialize the multi-source layer template data, use the internal method to convert the global multi-source layer template array into string type data, send it to the server through a request to update the database of the multi-source layer template data to the latest.
[0033] F. The parameters for creating a programming layer instance obtained through the interactive interface include: layer name, check box visibility indicator, initial display indicator, and template custom configuration parameter set.
[0034] G. Create and initialize a programming layer instance. The programming layer instance includes a unique identifier, multi-source layer type, layer parameters, layer object, initialization hook function, check hook function, uncheck hook function, add to map hook function, and remove hook function fields. The programming layer object includes an initialization method, add to layer method, check method, uncheck method, and remove method.
[0035] H. Create and initialize a programming layer instance. Based on the initial display identifier, determine whether to use the programming layer instance parameters as input parameters to execute the initialization hook function of the layer corresponding template and add it to the map hook function. After creation, the programming layer instance data is serialized into string type data and sent to the server through an HTTP request to update the layer data in the database to the latest version.
[0036] I. Create and initialize the layer tree node. The unique identification ID of the tree node is consistent with the layer instance ID corresponding to the node. The node name is updated according to the layer name. The node radio button visibility status is updated according to the check box visibility mark. The node check status is updated according to the initial display mark. After the creation is completed, the layer tree data is serialized into string type data and sent to the server through HTTP request to update the layer tree data in the database to the latest.
[0037] J. Each programming layer instance is associated with the layer tree, and the programming layer instance and layer tree node ID fields are matched. The global method is used to query the programming layer object according to the ID, and the layer tree node interaction callback event is bound to the programming layer object, so as to achieve the linkage effect of layer tree node and node matching programming layer object.
[0038] The following is a multi-source layer management tool based on a web-side map programmable layer implementation method in a language environment using a software method:
[0039] (1) Layer template interactive interface
[0040] This interface is used to design multi-source layer templates. The default parameters of the multi-source layer templates set through the interface include: template name, template English name, whether the same type is mutually exclusive, and node display scene; users can customize the number of template input parameters, parameter input method, and input parameter attribute name.
[0041] (2) Editing multi-source layer parameter interactive interface
[0042] This interface obtains parameters based on the multi-source layer template. The default parameters of the multi-source layer template are set through the interface, including: layer type, display check box, initial display, and several template parameters. The parameters obtained by the interface are used to create a programming layer object.
[0043] (3) Programming layer class
[0044] This class is used to instantiate programming layer instances, where ID is the unique identifier of this instantiated object, TYPE is the template type corresponding to the multi-source layer, DATA stores the specific configuration parameters of the layer, layerObj is the business side layer instance storage, and the business side layer instance refers to the smallest functional unit of user-defined business logic. The layerObj in the multi-source layer supports calling the business side layer instance interface; the update method in the class is used to update the programming layer status, and this method is called after the programming layer properties are modified;
[0045] (4) Design multi-source layer template code
[0046] This code segment is used to create and manage multi-source layer templates. The multi-source layer templates created through the interactive interface need to be parameter checked to ensure that the number of nodes in the layer tree is equal to and matches the number of instances in the programming layer collection. After confirmation of successful verification, it is sent to the database for data update.
[0047] (5) Layer management code:
[0048] This code implements the specific operations of the layer management function based on multi-source layers, including obtaining data from the database, creating multi-source layers, building a layer tree, organizing and managing multi-source layer templates, and parsing and associating data. The calling method and process are: (A) obtaining and parsing layer tree data; (B) obtaining and parsing layer data; (C) obtaining multi-source layer template data; (D) obtaining multi-source layer template parameters through the interactive interface; (E) saving the latest multi-source layer template data; (F) obtaining multi-source layer data through the interface according to the layer template blueprint; (G) creating a programming layer instance and a layer tree node; (H) associating the layer tree node with the programming layer instance data.
[0049] The present invention provides a method for implementing a programmable layer of a web-side map. There are many methods and ways to implement the technical solution. The above is only a preferred implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the protection scope of the present invention. All components not specified in this embodiment can be implemented using existing technologies.
Claims
1. A method for implementing a programmable layer of a Web-side map, characterized in that: The steps include: Step 1, create and store a multi-source layer template; Step 2: Create a programming layer instance and implement the interaction between the programming layer and the Web page; Step 3, create a layer tree object and associate and organize programming layer instance associations; Step 1 includes: Step 1-1, create a multi-source layer template; Step 1-2, storing multi-source layer templates; Step 1-1 includes: the multi-source layer template is a template used to create a programming layer instance; creating a multi-source layer template is used to configure the parameters of the multi-source layer template and various interactive functions; the parameter configuration of the multi-source layer template includes: template name, mutually exclusive identifiers of the same type, and node display scenes; the interactive function configuration of the multi-source layer template includes: initialization hook function, check hook function, uncheck hook function, add to map hook function, and remove hook function configuration; According to the parameters of the multi-source layer template and the interactive function configuration, the unique identifier LayerName of the multi-source layer template is generated, and finally a complete multi-source data template is formed; Step 1-2 includes: the multi-source layer template is saved in the server database. Before saving, the multi-source layer template stored in the server database is first traversed, and the server database is checked to see whether the same multi-source layer template already exists through the unique identifier LayerName match. If it exists, it is overwritten or cancelled according to the user's choice. If it does not exist, a storage operation is performed. The storage method is: the parameters of the multi-source layer template configured in step 1-1 and various interactive functions are converted into strings by the default method of the browser, and then sent to the server to be imported into the database for storage; Step 2 includes: Step 2-1, create a programming layer instance; Step 2-2, obtain the interaction function; Step 2-3, executable code conversion, convert the interactive function in string form into an executable interactive function in function form through the eval method, assign the converted interactive function to the hook function corresponding to the programming layer instance, and use the input parameters in the programming layer instance as the function input parameters; Step 2-4, binding the hook function converted in step 2-2 to the Web page interactive response event, to achieve interactive response between the programming layer hook function and the Web page; Step 2-1 includes: creating a programming layer instance according to a multi-source layer template, querying the corresponding multi-source layer template from the server database according to the type of programming layer instance to be created, creating a programming layer instance according to the parameters configured in the multi-source layer template, and setting the unique identifier LayerName of the programming layer instance to bind with the unique identifier of the multi-source layer template, thereby completing the creation of the programming layer instance; Step 2-2 includes: obtaining the multi-source layer template bound to the programming layer instance through the unique identifier LayerName, and obtaining the interactive function configured on the multi-source layer template; Step 3 includes: Step 3-1, create a layer tree object: The layer tree object is a tree structure, which is used to organize and manage the programming layer instances loaded and displayed on the web map. The hierarchical structure of the layer tree object is from low to high: programming layer instance, layer group object, layer tree object; programming layer instance is the leaf node of the layer tree object; one or more programming layer instances managed in a unified manner constitute a layer group object, and layer group objects constitute a layer tree object; Step 3-2, the layer tree object is associated with the web page; Step 3-3, the layer tree object is associated with the programming layer instance.
2. The method according to claim 1, characterized in that Step 3-2 includes: the user operates the layer tree object by operating the Web page; on the Web page, a tree-like Dom node is constructed according to the content and hierarchical structure of the layer tree object, and interactive events are bound to form a layer tree management interface. When the user operates the layer tree management interface, the layer tree object is processed accordingly in the bound interactive events.
3. The method according to claim 2, characterized in that Step 3-3 includes: when a new programming layer instance is added, the instance must be added to the layer tree object as a leaf node; when a programming layer instance is deleted, the corresponding node must be deleted from the layer tree at the same time; when leaf nodes on the layer tree are added, deleted, or the order is adjusted, the programming layer instances are added, deleted, or the order is adjusted accordingly on the web map.
Citation Information
Patent Citations
Data model and view standardization method and system based on DBVC framework
CN112527773A
Web application for argument maps
US20070027887A1
