A target marking method based on osmdroid map engine
By optimizing marker point management in the osmdroid map engine through a self-encapsulated MarkerEntity class and event listeners, the problem of high resource consumption is solved, efficient data storage and layer event listening are achieved, and development efficiency and flexibility are improved.
Patent Information
- Application Number
- CN202210702454.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-06-21
AI Technical Summary
Existing technologies cannot add new markers to existing marker points in the osmdroid map engine, resulting in high resource consumption. Furthermore, traditional persistent storage methods consume excessive memory resources, impacting development efficiency and flexibility.
By encapsulating a MarkerEntity class and using MyItemizedOverlayWithFocus layer and ItemizedIconOverlay.OnItemGestureListener event listeners, combined with memory queues and persistent database storage, the lifecycle management and resource utilization of marker points are optimized.
It improves the flexibility and resource utilization efficiency of marker points, reduces memory resource consumption, and achieves efficient data persistence storage and layer event listening.
Smart Images

Figure CN114896356B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to map target marking technology, specifically to a target marking method based on the osmdroid map engine. Background Technology
[0002] Currently, map target marker drawing is an essential component for developing map-type software. Among the known open-source Android map engines, osmdroid is a relatively user-friendly choice. However, due to the limitations of the original functions, it is not possible to add and embed a new marker point on the existing target marker during the development process. This leads to the modification of the logic and a large consumption of resources.
[0003] Traditional solutions do not add drag events to item points in the native Android package, nor can they handle the issue of adding markers within markers, thus failing to achieve flexibility and efficiency. Furthermore, the large number of processes may starve due to the event listening for layers across the entire map, requiring each map layer to go through its internal layer listening queue and its internal layer events, thereby increasing time complexity and consuming a great deal of resources. Traditional persistent storage only writes to the database based on changes in memory data, which consumes a great deal of memory resources and makes it very difficult for programmers to perform secondary development due to its inherent characteristics. Summary of the Invention
[0004] The main objective of this invention is to provide a target marker drawing method based on the osmdroid map engine, which encapsulates a marker class to replace the functionality of the item and provides a complete lifecycle.
[0005] Add markers to the OSMDROD map and add a MyItemizedOverlayWithFocus layer, along with an ItemizedIconOverlay.OnItemGestureListener event listener, making it more flexible and achieving more efficient resource utilization.
[0006] The technical solution adopted in this invention is: a method for drawing target markers based on the osmdroid map engine, comprising:
[0007] S1. Initialize map and marker. First, the system will initialize the MarkerEntity class. When the user manually triggers the listener layer, the system will store the newly added marker point data in the queue.
[0008] S2: Retrieve existing marker point data from the database. When the user triggers the map layer and marker layer, the system will automatically initialize their parameters, such as the map fragments of the current map layer and the latitude and longitude coordinates, name, description, and UID of the marker layer. At the same time, it will trigger the user's listening event for the newly created marker layer. Once the user selects to trigger the new marker listening event in the marker layer, the system will read the marker data location of the point from the database and convert it to latitude and longitude. The relevant data will be stored in the memory queue. At this point, the marker point operation process ends.
[0009] S3, save the layer target and its guiding object. After executing step S1, the data will be written into memory according to the corresponding layer target object to save the object in the layer and trigger the listener event of the marker layer. The system will use the latitude and longitude conversion method to create the corresponding utility class myMarkerEntity. The function of this class is to retrieve and reverse store the target layer object when it is stored, and update it during the transmission of its guiding object.
[0010] S4, the marker points are rendered onto the map layer via the View. After step S3 is completed, the layer target object writes the data to memory to save the layer object and triggers the marker layer listener event. The system then retrieves the relevant data of the layer target and its guiding object from the memory queue in step S3 and renders it onto the map layer through the View.OnClickListener interface. After step S2 is completed, this step is for the system initialization process. It reads the information of the original marker points in the database and then renders it onto the map layer through the View.OnClickListener interface. At this point, the memory process is complete.
[0011] S5 encapsulates the marker data and commits the transaction. The purpose of this step is to extract the current special marker point from memory and commit it to the backend database for persistent storage; upload the data in memory to the database for backup; and upload the marker point data in the queue to the database for persistent storage by committing the transaction. The detailed process involves creating a markerEntities object, storing its custom information data in the queue, and then encapsulating it again by creating a HashMap data object and its corresponding objects to store the collection of markers. The information is then uploaded through the update method in the Dao class.
[0012] S6. The transaction is committed to the database to complete persistent storage. It is added to the layer management in memory, and then added to the database in the management. After the Overlay is added to memory, the data packet type is determined, then markerEntity objects are created and stored through List objects. Finally, the sendMessage method of Handler is used to upload the data packet to the database one by one. At this point, the persistent storage work is completed.
[0013] S7. After the transaction is committed in step S6, the system will choose to execute step S2 or end the process based on its lifecycle.
[0014] Furthermore, the target marker drawing method based on the osmdroid map engine also includes a memory storage workflow, specifically:
[0015] S8 initializes all components, which are all components that implement human-computer interaction functions. Their functions include fragment manager initialization, map component initialization, etc.
[0016] S9 triggers the data listener. The system will trigger data listening events for various markers under the current fragment according to the preset code.
[0017] S10, determine whether the current top element of the stack has changed, i.e. whether the data being operated on has changed;
[0018] S11, if there are changes, recreate the layer and set the UUID, marker latitude and longitude information, etc.
[0019] S12, instantiate the methods drawTextToCenterTop, drawTextToLeftBottom, and drawTextToRightTop in the ImageUtil class. These methods determine the position based on the Paint class.
[0020] S13 calls multiple internal set methods to rewrite the changed data back into the memory queue, including information such as uid and marker coordinates; through the marker's method class, the relevant content is written into the memory queue query using the set method.
[0021] S14, if there are no changes, skip the current operation;
[0022] S15, the current fragment listener event continues to listen, waiting for the transaction commit listener event to be triggered, then the data in the queue will be committed to the database in the manner of committing the transaction.
[0023] Furthermore, the target marker drawing method based on the osmdroid map engine also includes a persistent storage process, specifically:
[0024] S16. Initialize and create entity classes. The entity classes contain overlays. Call the addoverlay method to store the entity classes into the layer management array in memory. After being added to the layer management array, the system will automatically complete the persistent storage.
[0025] S17, Instantiate Overlay, that is, call its getInstance() method to instantiate the method class, start the listener, and call the addToOverlayManager method to store the entity class into the layer management array in memory;
[0026] S18, after loading the layer management array, it will enter the persistent storage stage;
[0027] S19. After the transaction is completed, the DBManagerUtil class is instantiated through the getInstance() method and persistent storage is implemented through its internal dbStorage method; the data is stored in memory based on the markerinfo method. The Markerinfofragment inherits the fragment interface through the onclickListener() method of View and implements the onClick() method of data submission to store the marker information in the cache queue.
[0028] S20, the stored information is persisted through the getInstance() method;
[0029] S21. Display the data on the mapView by adding a marker layer in the current view using the add method in the getOverlays method of mapView.
[0030] S22, after the transaction is committed, the information in the context is stored in the sqlite database using the getDao method.
[0031] Advantages of this invention:
[0032] This invention addresses map drawing issues by proposing a method to upgrade existing items using markers. This solves the problems of adding layers to marker points and high resource consumption. Furthermore, the OSMDROD map engine allows for the addition of common map features such as overlays and polylines. As is well known, OSMDROD obtains a collection of all overlays through the `getOverlays()` method of `MapView` and then adds them to layers using the `add()` method. Adding overlays in a `MapView` requires implementing the `overlay` interface. This invention solves the problem of adding markers within markers by adding a custom listener layer.
[0033] What makes this invention unique is that the marker drawing at the marker point is a self-encapsulated ImageUtil class, in which layers are embedded based on the Bitmap class. The information in the layer changes color or icon style according to the set position of the set method, instead of adding it using the traditional Item point. Its internal elements implement polymorphism, thereby improving its flexibility.
[0034] After data dynamically changes, it is retrieved from the memory object and loaded into the database only after the transaction is committed. Traditional data persistence only updates the changed parts of the data in real time. While this ensures data security, it consumes more memory resources. Comparing specific data persistence with traditional data persistence, this approach reduces data consumption while ensuring the automatic retention of important data information under special operations.
[0035] In addition to the objectives, features, and advantages described above, the present invention has other objectives, features, and advantages. The invention will now be described in further detail with reference to the figures. Attached Figure Description
[0036] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0037] Figure 1 This is the data interaction diagram of the present invention;
[0038] Figure 2 This is a flowchart of the memory storage process of the present invention;
[0039] Figure 3 This is a schematic diagram of the persistent storage of the present invention. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0041] refer to Figures 1 to 3 A method for drawing target markers based on the osmdroid map engine, comprising:
[0042] S1. Initialize the map and marker. First, the system initializes the MarkerEntity class (this class is responsible for reading and sending data packets containing detailed information about marker points in the database, and inherits from BaseDaoEnabled).<T,TD> (The class implements its functionality by calling the Serializable interface. When the user manually triggers the listener layer, the system will store the newly added marker point data in the queue.)
[0043] First, the system reads the detailed information of the marker points in the database through the MarkerEntity class. When the user manually triggers the listening layer, the system stores the newly added marker point data in the queue. When the one-click send button is triggered, the system uploads the marker point data to the backend database for persistent storage.
[0044] S2: Retrieve existing marker point data from the database. When the user triggers the map layer and marker layer, the system will automatically initialize their parameters, such as the map fragments of the current map layer and the latitude and longitude coordinates, name, description, and UID (a kind of identity index for marker points) of the marker layer. At the same time, it will trigger the user's listening event for the newly created marker layer. Once the user selects to trigger the new marker listening event in the marker layer, the system will read the marker data location of the point from the database and convert it to latitude and longitude. The relevant data will be stored in the memory queue. At this point, the marker point operation process ends.
[0045] S3, save the layer target and its guiding object. After executing step S1, the data will be written into memory according to the corresponding layer target object to save the object in the layer and trigger the listener event of the marker layer. The system will use the latitude and longitude conversion method to create the corresponding utility class myMarkerEntity. The function of this class is to retrieve and reverse store the target layer object when it is stored, and update it during the transmission of its guiding object.
[0046] S4, the marker points are rendered onto the map layer via the View. After step S3 is completed, the layer target object writes the data to memory to save the layer object and triggers the marker layer listener event. The system then retrieves the relevant data of the layer target and its guiding object from the memory queue in step S3 and renders it onto the map layer through the View.OnClickListener interface. After step S2 is completed, this step is for the system initialization process. It reads the information of the original marker points in the database and then renders it onto the map layer through the View.OnClickListener interface. At this point, the memory process is complete.
[0047] S5 encapsulates the marker data and commits the transaction. This step aims to extract the current specific marker point from memory and commit it to the backend database for persistent storage; upload the data in memory (instantaneous data) to the database for backup (persistent data); and upload the marker point data in the queue to the database for persistent storage by committing the transaction. The detailed process involves creating a markerEntities object (of type List), storing its custom information data in the queue, and then encapsulating it again by creating a HashMap data object and its associated objects to store the collection of markers. The information is then uploaded through the update method in the Dao class.
[0048] S6. The transaction is committed to the database to complete persistent storage. The layer is added to the memory management, and then added to the database in the management. After the Overlay (utility class for map marker layers) is added to memory, the data packet type is determined, and then markerEntity objects are created and stored through List objects. Finally, the sendMessage method of Handler is used to upload the data packet to the database one by one. At this point, the persistent storage work is completed.
[0049] S7. After the transaction is committed in step S6, the system will choose to execute step S2 or end the process based on its lifecycle.
[0050] The target marker drawing method based on the osmdroid map engine also includes memory storage.
[0051] The workflow is as follows:
[0052] S8 initializes all components, which are all components that implement human-computer interaction functions. Their functions include fragment manager initialization, map component initialization, etc.
[0053] S9 triggers the data listener. The system will trigger data listening events for various markers under the current fragment according to the preset code.
[0054] S10, determine whether the current top element of the stack has changed, i.e. whether the data being operated on has changed;
[0055] S11, if there are changes, recreate the layer and set the UUID, marker latitude and longitude information, etc.
[0056] S12, instantiate the methods drawTextToCenterTop, drawTextToLeftBottom, and drawTextToRightTop in the ImageUtil class (which is a method class used to fill custom icons in the marker layer). These methods determine the position based on the Paint method class.
[0057] S13 calls multiple internal set methods to rewrite the changed data into the memory queue, including information such as uid and marker coordinates; through the marker's method class, the relevant content is written into the memory queue query using the set method (preserving its object type).
[0058] S14, if there are no changes, skip the current operation;
[0059] S15, the current fragment listener event continues to listen, waiting for the transaction commit listener event to be triggered, then the data in the queue will be committed to the database in the manner of committing the transaction.
[0060] The target marker drawing method based on the osmdroid map engine also includes a persistent storage process, specifically:
[0061] S16. Initialize and create an entity class (this entity class is instantiated through the getInstance method of OverlayManager (this class is used to store all layers, and its storage method is one layer to one entity class)). The entity class contains overlay. Call the addoverlay method to store the entity class into the layer management array in memory. After it is added to the layer management array, the system will automatically complete the persistent storage.
[0062] Creating an entity class simply involves instantiating the method class using the getInstance() method;
[0063] S17, Instantiate Overlay, that is, call its getInstance() method to instantiate the method class, start the listener, and call the addToOverlayManager method to store the entity class (listening for information triggered inside the layer) into the layer's management array (i.e., memory queue) in memory.
[0064] Instantiate markerEnitity by calling its getInstance() method to instantiate the method class and start its layer marker's event listener;
[0065] S18, after loading the layer management array (i.e., the memory queue), will enter the persistent storage stage (uploaded to the backend database for persistent storage by committing transactions).
[0066] S19. After the transaction is completed, the DBManagerUtil class is instantiated through the getInstance() method and its internal dbStorage method (gets the index of the triggering target, clears the expired data in the memory queue, then rewrites the marker data, instantiates markerEnitity, that is, calls its getInstance() method to implement method class instantiation, and starts the listener event of its layer marker) to achieve persistent storage operation; based on the markerinfo method, the data is stored in memory. The Markerinfofragment inherits the fragment interface through the onclickListener() method of View and implements the onClick() method of data submission to store the marker information in the cache queue.
[0067] If the system determines that the marker layer is not the top element of the fragment stack, it will recreate the object MyGeoPointClass and read the data from the database object by inheriting the BaseDaoEnabled method.
[0068] S20, the stored information is persisted through the getInstance() method;
[0069] S21. Display the data on the mapView by adding a marker layer in the current view using the add method in the getOverlays method of mapView.
[0070] S22, after the transaction is committed, the information in the context is stored in the sqlite database using the getDao method.
[0071] The purpose of this invention is to provide a new map drawing method based on the OSMDRoid engine. Addressing the bottleneck limitation of the OSMDRoid engine, which only allows the use of item points in map drawing and cannot perform other operations, a new solution is proposed. This solution encapsulates a marker class to replace the functionality of items and provides a complete lifecycle. By adding markers to the OSMDRoid map and primarily using the MyItemizedOverlayWithFocus layer with ItemizedIconOverlay.OnItemGestureListener event listener, the system becomes increasingly flexible and achieves more efficient resource utilization.
[0072] On the replacement layer, a new and improved method for replacing the marker is based on the `decodeResource` method of `BitmapFactory`, which stores relevant information and the icon. The `drawSTextToCenterTop` method of `ImageUtil` is used to set the string data to a custom size and center it on the icon. An annotation is added below the marker using `drawTextToLeftBottom`.
[0073] This invention, when changing layer styles, embeds a marker that allows for customization and creates a separate listening layer with a complete lifecycle. Upon receiving a gesture from the marker, the current layer monitors the gesture in real-time, detects changes, tracks the gesture update position at a frequency of 60Hz, and automatically updates the information after the gesture ends. Similarly, the previous listening layer is automatically destroyed rather than hidden. This approach ensures both flexibility and low consumption of listening stack resources.
[0074] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for drawing target markers based on the OSMDRODroid map engine, characterized in that, include: S1. Initialize map and marker. First, the system will initialize the MarkerEntity class. When the user manually triggers the listener layer, the system will store the newly added marker point data in the queue. S2: Retrieve existing marker point data from the database. When the user triggers the map layer and marker layer, the system will automatically initialize their parameters, including the map fragments of the current map layer and the latitude and longitude coordinates, name, description, and UID of the marker layer. At the same time, it will trigger the user's listener event for the newly created marker layer. Once the user selects to trigger the new marker listener event in the marker layer, the system will read the marker data location of the point from the database, convert it through latitude and longitude, and store the relevant data in the memory queue. At this point, the marker point operation process ends. S3, save the layer target and its guiding object. After executing step S1, the data will be written to memory according to the corresponding layer target object. Save the objects in the layer and write them to memory, trigger the listener event of the marker layer. The system will use the latitude and longitude conversion method to create the corresponding utility class myMarkerEntity. The function of this class is to retrieve and reverse store the layer target object when it is stored, and update it during the transmission of its guiding object. S4, the marker points are rendered onto the map layer through the View. After step S3 is completed, the layer target object data is written into memory, the layer object is saved, and the marker layer listener event is triggered. The system will then retrieve the relevant data of the layer target and its guiding object in the memory queue in step S3, and implement the function of rendering it onto the map layer through the View.OnClickListener interface. S5 encapsulates the marker data and commits the transaction. The purpose of this step is to extract the current special marker point from memory and commit it to the backend database for persistent storage. Upload the data in memory to the database for backup; upload the marker data in the queue to the database for persistent storage by committing transactions. The detailed process is to create a markerEntities object, store its custom information data of the marker in the queue, and then encapsulate it by creating a HashMap data object and its guide object to store the collection of markers. The information is uploaded through the update method in the Dao class. S6, the transaction is committed to the database to complete persistent storage, added to the layer management in memory, and then added to the database in the layer management; after the Overlay is added to memory, the data packet type is determined, then a markerEntity object is created and stored through a List object, and finally the sendMessage method of the Handler is used to upload the data packet to the database one by one. At this point, the persistent storage work is completed. S7. After the transaction is committed in step S6, the system will choose to execute step S2 or end the process based on its lifecycle.
2. The target marker drawing method based on the OSMDRODroid map engine according to claim 1, characterized in that, It also includes the memory storage workflow, specifically: S8 initializes all components, which are all components that implement human-computer interaction functions. Their functions include fragment manager initialization and map component initialization. S9 triggers the data listener. The system will trigger data listening events for various markers under the current fragment according to the preset code. S10, determine whether the current top element of the stack has changed, i.e. whether the data being operated on has changed; S11, if there are changes, recreate the layer and set the UUID, marker latitude and longitude information; S12, instantiate the methods drawTextToCenterTop, drawTextToLeftBottom, and drawTextToRightTop in the ImageUtil class. These methods determine the position based on the Paint class. S13 calls multiple set methods within it to rewrite the changed data back into the memory queue, including uid and marker coordinate information; Using the marker's methods, the relevant content is written into the memory queue via the set method; S14, if there are no changes, skip the current operation; S15, the current fragment listener event continues to listen, waiting for the transaction commit listener event to be triggered, then the data in the queue will be committed to the database in the manner of committing the transaction.
3. The target marker drawing method based on the OSMDRODroid map engine according to claim 1, characterized in that, It also includes persistent storage processes: Initialize and create entity classes, which contain overlays. Call the addoverlay method to store the entity class into the layer management array in memory. After being added to the layer management array, the system will automatically complete the persistent storage. Specifically: S17, Instantiate Overlay, that is, call its getInstance() method to instantiate the method class, start the listener, and call the addToOverlayManager method to store the entity class into the layer management array in memory; S18, after loading the layer management array, it will enter the persistent storage stage; S19. After the transaction is completed, the DBManagerUtil class is instantiated through the getInstance() method and persistent storage is implemented through its internal dbStorage method; the data is stored in memory based on the markerinfo method. The Markerinfofragment inherits from fragment and implements the onClick() method of the View through the onclickListener() interface to store the marker information in the cache queue by submitting the data. S20, the stored information is persisted through the getInstance() method; S21, display the data on mapView, and add marker layers in the current view using the add method in the getOverlays method of mapView; S22, after the transaction is committed, the getDao method stores the specific information in the context in the sqlite database.
Citation Information
Patent Citations
Multi-thematic chart displaying method based on spatial objects
CN108334564A
Dynamic scaling of geospatial data on maps
US11175157B1