WMS land parcel data acquisition method and device, and medium
By deeply integrating Tianditu service with the OpenLayers library, the problems of map service interface differences and land parcel information acquisition have been solved, enabling efficient and maintainable land parcel data display and improving development efficiency and interactive experience.
Patent Information
- Application Number
- CN202511532066.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-02-03
AI Technical Summary
In existing technologies, map service provider API interfaces vary greatly, requiring developers to write cumbersome adaptation code. WMS layers have difficulty directly obtaining plot attributes and geometric information, resulting in limited interactive capabilities. Furthermore, map logic is coupled with business code, making maintenance and expansion difficult.
By deeply integrating Tianditu service, OpenLayers library and componentization technology, we can directly obtain and highlight land parcel information in WMS layers. We use Tianditu API key, JavaScript library, coordinate transformation library and OpenLayers library to build a map development environment, register map click events, obtain the geometric and attribute information of land parcels and highlight them.
It improved development efficiency, user experience, and code maintainability, enabled direct acquisition and highlighting of land parcel data, simplified the development process, and increased the degree of componentization.
Smart Images

Figure CN121456072A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of geographic information systems, and particularly relates to a WMS plot data acquisition method, device and medium. BACKGROUND
[0002] With the wide application of geographic information systems (GIS), more and more projects need to integrate map services in web pages and realize the visualization and interaction of plot data. In the prior art, various map APIs (such as Baidu Map, Gaode Map, etc.) are combined with front-end map libraries (such as Leaflet, Mapbox, etc.) to realize the loading and display of maps.
[0003] However, the prior art still has many problems. First, the API interfaces of different map service providers are quite different, and developers need to write adaptation codes for different services, which is tedious and has poor code reusability. Second, the traditional Web Map Service (WMS) layer provides map data in the form of pictures, which makes it difficult to directly obtain the attribute and geometric information of specific plots, limiting the interaction ability of plot data. Finally, in the existing scheme, the highlight display and information acquisition of the clicked plot usually need to introduce additional vector data services or complex data analysis logic, which increases the development difficulty and system complexity. The degree of componentization is low, and the existing implementation often couples the map logic with the business code, which is not conducive to maintenance and extension, especially in modern front-end frameworks such as Vue, there is a lack of reusable map component encapsulation.
[0004] Therefore, how to deeply integrate the MapWorld service, OpenLayers library and componentization technology to realize the direct acquisition and highlight display of plot information in the WMS layer and effectively improve the development efficiency, interaction experience and code maintainability has become a technical problem to be solved. SUMMARY
[0005] The embodiments of the present application provide a WMS plot data acquisition method, device and medium, which solve the technical problem of how to deeply integrate the MapWorld service, OpenLayers library and componentization technology to realize the direct acquisition and highlight display of plot information in the WMS layer and effectively improve the development efficiency, interaction experience and code maintainability.
[0006] In a first aspect, the embodiments of the present application provide a WMS plot data acquisition method, which comprises: registering a developer account through a MapWorld platform to obtain a MapWorld API key; introducing a MapWorld JavaScript library, an OpenLayers library and a coordinate conversion library based on the MapWorld API key to build a map development environment with coordinate system conversion capability; creating a GIS map public component based on the map development environment, and calling the OpenLayers library and the MapWorld JavaScript library to generate a map instance; registering a map click event in a WMS service layer in the map instance, and sending a request to the WMS service after obtaining the map click event to obtain geometric information and attribute information of a plot corresponding to the map click event.
[0007] In an implementation manner of the present application, the developer account is registered through the MapWorld platform to obtain the MapWorld API key, specifically comprising: accessing the MapWorld platform, and performing a registration and authentication process of the developer account; logging in the authenticated developer account to enter an application management interface, and creating an application project; in the application project, selecting a map service type to be called and submitting an application configuration; and generating the MapWorld API key based on the application configuration.
[0008] In an implementation manner of the present application, the MapWorld JavaScript library, the OpenLayers library and the coordinate conversion library are introduced based on the MapWorld API key to build the map development environment with the coordinate system conversion capability, specifically comprising: determining a header area in the application project to obtain a library file introduction position; adding introduction codes of the MapWorld JavaScript library, the OpenLayers library and the coordinate conversion library through a CDN link based on the library file introduction position to complete the introduction of the MapWorld JavaScript library, the OpenLayers library and the coordinate conversion library; starting the application project to detect whether there is a loading error information of the library file, and building the map development environment with the coordinate system conversion capability.
[0009] In an implementation manner of the present application, the application project is started to detect whether there is a loading error information of the library file, and the map development environment with the coordinate system conversion capability is built, specifically comprising: if there is the loading error information, prompting a user to check whether the CDN link is complete, whether the MapWorld API key is accurate and / or whether the introduction code is written in a standard, until there is no loading error information; and if there is no loading error information, completing the building of the map development environment with the coordinate system conversion capability.
[0010] In an implementation manner of the present application, based on a map development environment, a GIS map public component is created, and an OpenLayers library and a Tianditu JavaScript library are called to generate a map instance, specifically including: creating the GIS map public component in an application project; initializing a map container in the GIS map public component to generate an initial map instance; configuring a coordinate system, a center point coordinate and an initial zoom level of the initial map instance to generate a map view with a specified display range; based on the Tianditu JavaScript library, creating a Tianditu image layer, and adding the Tianditu image layer to the map view with the specified display range to generate a map instance containing a base map; based on a WMS layer interface in the OpenLayers library, creating a WMS service layer, and superimposing the WMS service layer on the map instance containing the base map to generate a map instance containing a multi-layer structure.
[0011] In an implementation manner of the present application, the WMS service layer in the map instance registers a map click event, specifically including: calling a listening interface associated with the map instance in the OpenLayers library; when the listening interface obtains the map click event, extracting coordinate information of the map click event, and setting a response processing function of the map click event to complete registration of the map click event.
[0012] In an implementation manner of the present application, after obtaining the map click event, a request is sent to the WMS service to obtain geometric information and attribute information of a plot corresponding to the map click event, specifically including: in response to the map click event obtained by the listening interface, executing the response processing function to extract coordinate point information contained in the click demand; calling a coordinate conversion library to convert the coordinate point information from a map display coordinate system to a coordinate system conforming to the requirements of the WMS service; based on the converted coordinate point information, constructing a request conforming to the WMS standard through the OpenLayers library, and sending the request to a server providing the WMS service layer; receiving response data returned by the server, and parsing the response data to extract geometric information and attribute information of a target plot.
[0013] In an implementation manner of the present application, after obtaining the geometric information and attribute information of the plot corresponding to the map click event, the method further includes: based on the geometric information, calling a vector graphics drawing interface of the OpenLayers library to create a vector element corresponding to the geometric information; setting a fill color and a border attribute of the vector element to form a highlight display effect; adding the highlight display effect to a vector layer of the map instance to make the plot corresponding to the map click event present a highlight state on the map instance; associating the attribute information with the highlighted vector element to support attribute query and interactive operation of the plot corresponding to the click demand.
[0014] In a second aspect, the embodiments of the present application further provide a WMS plot data acquisition device, comprising: at least one processor; and a memory in communication connection with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: register a developer account through a MapWorld platform to obtain a MapWorld API key; based on the MapWorld API key, introduce a MapWorld JavaScript library, an OpenLayers library and a coordinate conversion library to build a map development environment with coordinate system conversion capability; based on the map development environment, create a GIS map public component, and call the OpenLayers library and the MapWorld JavaScript library to generate a map instance; register a map click event in a WMS service layer in the map instance, and send a request to a WMS service after obtaining the map click event to obtain geometric information and attribute information of a plot corresponding to the map click event.
[0015] In a third aspect, the embodiments of the present application further provide a nonvolatile computer storage medium for WMS plot data acquisition, which stores computer executable instructions, and the computer executable instructions are configured to: register a developer account through a MapWorld platform to obtain a MapWorld API key; based on the MapWorld API key, introduce a MapWorld JavaScript library, an OpenLayers library and a coordinate conversion library to build a map development environment with coordinate system conversion capability; based on the map development environment, create a GIS map public component, and call the OpenLayers library and the MapWorld JavaScript library to generate a map instance; register a map click event in a WMS service layer in the map instance, and send a request to a WMS service after obtaining the map click event to obtain geometric information and attribute information of a plot corresponding to the map click event.
[0016] The WMS plot data acquisition method, device and medium provided by the embodiments of the present application have the following beneficial effects: BRIEF DESCRIPTION OF DRAWINGS The accompanying drawings, which are included to provide a further understanding of the present application, constitute a part of the present application, illustrate the illustrative embodiments of the present application and their description serve to explain the present application, and do not constitute improper limitations on the present application. In the drawings: Figure 1 A WMS plot data acquisition method flowchart is provided for the embodiments of the present application; Figure 2 A WMS plot data acquisition device internal structure schematic diagram is provided for the embodiments of the present application. DETAILED DESCRIPTION
[0017] In order to make the purposes, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described below in connection with specific embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0018] The embodiments of the present application provide The technical solutions provided by the embodiments of the present application will be described in detail below with reference to the drawings.
[0019] Figure 1 A WMS plot data acquisition method flowchart is provided in the embodiments of the present application. As shown in the figure, Figure 1 The WMS plot data acquisition method provided by the embodiments of the present application specifically includes the following steps: Step 10: Register a developer account through the MapWorld platform to obtain a MapWorld API key.
[0020] As an optional embodiment, the developer account is registered through the MapWorld platform to obtain the MapWorld API key, which specifically can include: step 101: access the MapWorld platform and perform the registration and authentication process of the developer account.
[0021] In this step, first access the official platform of MapWorld, enter the developer related entry page, find the developer account registration entry in the page, and fill in the necessary registration information according to the prompt. These registration information usually includes but is not limited to the basic identity information, contact information, etc. of the individual or enterprise; after submitting the registration information, the account authentication process is required according to the platform requirements. The authentication process will provide corresponding identity credentials or qualification documents according to the difference of user types. After the platform audit is passed, the developer account is registered and authenticated.
[0022] Step 102: Log in to the authenticated developer account to enter the application management interface and create an application project.
[0023] In this step, after completing the account registration and authentication, the authenticated developer account is used to log in to the MapWorld platform. After successful login, the application management interface is entered in the function navigation area of the platform. In the application management interface, the create application option is clicked to start the creation process of the application project. In the process of creating the application project, the related basic information of the application needs to be filled in according to the platform prompt, such as the application name, the application purpose description, etc. After completing the filling of these information, the creation request is submitted, and a new application project is generated.
[0024] Step 103: In the application project, select the type of map service that needs to be called and submit the application configuration; generate the MapWorld API key based on the application configuration.
[0025] In this step, after the application project is created, enter the configuration interface of the application project. In the configuration interface, various types of map services provided by the MapWorld platform will be listed. The developer needs to select the specific map service type that needs to be called from these service types according to the project requirements. After selection, other related configuration items of the application are set reasonably to ensure that the configuration meets the project function requirements and platform specifications. After all configuration items are set, submit the application configuration information and wait for the platform to confirm the configuration information. When the application configuration is submitted and confirmed by the platform, the platform will automatically generate the corresponding MapWorld API key based on the configuration information of the application. The developer can view and obtain the generated API key in the application project details interface or a special key management area. This key will be used for identity verification and permission identification when calling MapWorld related services in the project later Step 20: Based on the MapWorld API key, introduce the MapWorld JavaScript library, OpenLayers library, and coordinate conversion library to build a map development environment with coordinate system conversion capability.
[0026] As an optional embodiment, based on the MapWorld API key, introduce the MapWorld JavaScript library, OpenLayers library, and coordinate conversion library to build a map development environment with coordinate system conversion capability. Specifically, it can include: step 201: determine the header area in the application project to obtain the introduction position of the library file.
[0027] In this step, for a Vue project, the header area mainly refers to the index.html file of the project, or the Vue component inside <template>The two positions are the core areas commonly used for introducing external library files in front-end projects. By locating the two key positions, the subsequent introduction positions of the library files can be determined, which makes a good preparation for the subsequent introduction of external resources such as the MapWorld JavaScript library, the OpenLayers library, and the coordinate conversion library, and ensures that the subsequent library files can be correctly identified and loaded by the project, thereby supporting the development and implementation of subsequent map-related functions.
[0028] Step 202: Based on the library file introduction position, add the introduction code of the MapWorld JavaScript library, the OpenLayers library, and the coordinate conversion library through the CDN link to complete the introduction of the MapWorld JavaScript library, the OpenLayers library, and the coordinate conversion library.
[0029] In this step, based on the determined library file introduction position, the introduction code of the MapWorld JavaScript library, the OpenLayers library, and the coordinate conversion library is added through the CDN link. For the MapWorld JavaScript library, the <script>标签代码,且要注意在链接中正确配置相关参数,以确保天地图JavaScript库能顺利引入;对于OpenLayers库,不仅要添加其JavaScript库的CDN链接对应的<script>标签代码,还需添加其CSS文件的CDN链接对应的<link>标签代码,保证OpenLayers库的相关功能和样式都能正常加载;对于坐标转换库,同样在头部区域添加该库CDN链接对应的<script>标签代码;通过上述操作,即可完成天地图JavaScript库、OpenLayers库及坐标转换库的引入,为后续地图功能的实现奠定基础。
[0030] 步骤203:启动应用项目,以检测是否存在库文件的加载报错信息,并构建具备坐标系转换能力的地图开发环境。
[0031] 作为一种可选的实施例,启动应用项目,以检测是否存在库文件的加载报错信息,并构建具备坐标系转换能力的地图开发环境,具体可以包括:步骤2031:若存在加载报错信息,则提醒用户检查CDN链接是否完整、天地图API密钥是否准确和 / 或引入代码的编写是否规范,直至不存在加载报错信息。
[0032] 本步骤中,在完成天地图JavaScript库、OpenLayers库及坐标转换库的引入并启动项目后,需优先查看控制台以确认是否存在加载报错信息;若控制台显示加载报错,需针对性开展排查工作,首先检查各库文件对应的CDN链接,确认链接是否完整、无缺失或拼写错误,避免因链接问题导致库文件无法正常获取;其次核实天地图API 密钥,确保密钥与在天地图官网申请的信息完全一致,无错输、漏输或与当前应用不匹配的情况,因为密钥错误会直接阻碍天地图服务的调用;同时检查库文件引入代码的编写规范度,确认标签格式、参数配置等是否符合语法要求,排除因代码编写不规范引发的加载异常。通过上述多维度的排查与修正,反复验证并调整,直至控制台不再出现任何加载报错信息,确保后续地图相关功能开发可基于稳定的环境推进。
[0033] 步骤2032:若不存在加载报错信息,则完成具备坐标系转换能力的地图开发环境的构建。
[0034] 本步骤中,若启动项目后控制台无任何加载报错信息,说明天地图JavaScript库、OpenLayers库及坐标转换库均已成功加载,此时便完成了具备坐标系转换能力的地图开发环境的构建,该环境可支撑后续地图初始化、WMS服务加载及地块数据获取等相关功能的开发与实现。
[0035] 步骤30:基于地图开发环境,创建GIS地图公共组件,并调用OpenLayers库及天地图JavaScript库,以生成地图实例。
[0036] 作为一种可选的实施例,基于地图开发环境,创建GIS地图公共组件,并调用OpenLayers库及天地图JavaScript库,以生成地图实例,具体可以包括:步骤301:在应用项目中创建GIS地图公共组件。
[0037] 本步骤中,在创建GIS地图公共组件时,需先在项目的指定组件目录下新建专门的文件夹及对应的组件文件,该组件文件将用于集中封装所有与地图操作相关的逻辑,为后续项目中其他组件调用地图功能提供统一接口,确保地图功能的可重用性与可维护性。
[0038] 步骤302:在GIS地图公共组件中初始化地图容器,以生成初始地图实例。
[0039] 本步骤中,在已创建的GIS地图公共组件内部,首要任务是初始化地图容器以生成初始地图实例,借助OpenLayers库提供的API接口,先定义地图容器的目标挂载节点,明确地图将在页面中的展示位置;随后,通过OpenLayers的地图初始化方法,配置地图所需的基础参数,添加天地图影像图层、天地图注记图层以及WMS服务图层;完成配置后,执行初始化操作,即可生成具备基础显示功能的初始地图实例,该初始化实例将作为后续加载WMS服务、获取地块数据等操作的基础载体。
[0040] 步骤302:配置初始地图实例的坐标系、中心点坐标及初始缩放级别,以生成具有指定显示范围的地图视图。
[0041] 本步骤中,首先,依据天地图服务及OpenLayers库的适配要求,为初始地图实例指定标准的坐标系,该坐标系将作为后续地图数据加载、坐标转换及交互操作的基准,保证地图数据在空间参考上的一致性;接着进行中心点坐标的设置,根据项目所需的地图核心展示区域,确定对应的中心点坐标,并通过OpenLayers提供的坐标转换方法,将该中心点坐标转换为与已配置坐标系相匹配的格式,确保中心点能精准定位到目标区域,使地图加载后初始视野聚焦于关键展示范围;最后配置初始缩放级别,结合项目对地图初始显示细节程度的需求,设定合适的初始缩放级别,该级别将决定地图加载完成后用户首次看到的地图范围大小与细节丰富度,既避免因缩放级别过低导致视野过广、关键区域不突出,也防止因缩放级别过高导致视野过窄、无法呈现整体区域;完成坐标系、中心点坐标及初始缩放级别的配置后,将这些参数整合到地图视图的初始化设置中,随初始地图实例的生成同步生效,最终得到具有指定显示范围的地图视图。
[0042] 步骤303:基于天地图JavaScript库,创建天地图影像图层,并将天地图影像图层添加到具有指定显示范围的地图视图中,以生成包含底图的地图实例。
[0043] 本步骤中,在完成具有指定显示范围的地图视图配置后,基于已引入的天地图JavaScript库,开始创建天地图影像图层;通过调用OpenLayers库中用于创建瓦片图层的相关API,构建天地图影像图层实例,在该实例的配置中,需指定天地图影像服务的数据源地址,确保数据源能正确关联到天地图官方提供的影像服务,同时设置与地图视图一致的坐标系,保证影像图层与地图视图在空间参考上匹配;天地图影像图层创建完成后,将其添加到已配置好指定显示范围的地图视图中,通过OpenLayers地图实例提供的图层添加方法,将天地图影像图层纳入地图视图的图层集合,与之前可能存在的其他基础图层协同作用;此时,地图视图会加载并渲染天地图影像图层的内容,使地图实例具备清晰的地理影像底图,最终生成包含底图的地图实例,为后续加载WMS服务图层、实现地块数据展示等功能提供基础地理空间载体。
[0044] 步骤304:基于OpenLayers库中的WMS图层接口,以创建WMS服务图层,并将WMS服务图层叠加到包含底图的地图实例中,以生成包含多层结构的地图实例。
[0045] 本步骤中,在已生成包含底图的地图实例基础上,通过调用OpenLayers库内对应的图像图层类及WMS数据源类,构建WMS服务图层的核心结构;在配置过程中,需准确填写WMS服务的地址,确保能与目标WMS服务端建立有效连接;同时设置WMS服务的关键参数,包括指定需加载的图层名称、配置图层的瓦片化处理方式,若有数据筛选需求,还需合理设置对应的过滤条件,此外还需明确服务端类型以保障交互兼容性;完成这些配置后,进一步设定WMS服务图层的层级优先级与名称标识,确保该图层能在地图实例中处于合适的显示层级,既不被底图或其他基础图层遮挡,又能清晰呈现地块相关数据;WMS服务图层创建完成后,通过OpenLayers地图实例提供的图层添加方法,将其叠加到已包含底图的地图实例中;此时,地图实例会将WMS服务图层与原有的天地图影像底图、注记图层等进行整合,形成包含多层结构的地图实例;其中,底图提供基础地理空间背景,WMS服务图层则叠加呈现特定的地块数据信息,各图层按照预设的层级优先级有序渲染,最终实现多层数据在同一地图视图中的协同展示,为后续点击获取地块具体信息等交互操作提供数据载体与视觉基础。
[0046] 步骤40:在地图实例中的WMS服务图层中注册地图点击事件,并在获取地图点击事件后向WMS服务发送请求,以获得与地图点击事件对应的地块的几何信息与属性信息。
[0047] 作为一种可选的实施例,在地图实例中的WMS服务图层注册地图点击事件,并在获取地图点击事件后向WMS服务发送请求,以获得与地图点击事件对应的地块的几何信息与属性信息,具体可以包括:步骤401:调用OpenLayers库中与地图实例关联的监听接口。
[0048] 步骤402:当监听接口获取地图点击事件时,提取地图点击事件的坐标信息,并设置地图点击事件的响应处理函数,以完成地图点击事件的注册。
[0049] 本步骤中,当通过OpenLayers库中与地图实例关联的监听接口捕捉到地图点击事件后,首先从该点击事件对象中提取出关键的坐标信息,这一坐标信息将作为后续定位点击位置、关联WMS服务图层数据的核心依据,确保能精准定位到用户点击的地图区域;随后,为该地图点击事件设置专门的响应处理函数。在响应处理函数的定义中,需识别点击位置对应的WMS服务图层、获取该图层下点击区域的地块数据、移除之前可能存在的旧有高亮图层以避免干扰等;将定义好的响应处理函数与地图点击事件进行绑定,使得当监听接口检测到用户点击地图的操作时,能自动触发该处理函数执行预设逻辑,从而完成地图点击事件的完整注册,为后续通过点击操作获取地块具体信息、实现地块高亮等功能提供触发机制与处理通道。
[0050] 步骤403:响应于监听接口获取的地图点击事件,执行响应处理函数,以提取点击需求包含的坐标点信息。
[0051] 本步骤中,当监听接口成功捕捉到地图点击事件后,会立即触发预先绑定的响应处理函数,开始执行点击事件的后续逻辑;在响应处理函数的执行过程中,首要步骤是从触发的地图点击事件对象中,精准提取出该点击操作所对应的坐标点信息,这一坐标点信息直接关联着用户在地图上的具体点击位置,是后续进一步定位WMS服务图层中对应地块、获取地块数据的核心基础数据;通过对点击事件对象的解析,确保提取到的坐标点信息格式与地图实例所采用的坐标系保持一致,为后续基于该坐标点信息开展的各项数据交互操作提供准确的空间位置依据,保障后续获取地块数据等流程能精准对应到用户点击的地图区域。
[0052] 步骤404:调用坐标转换库,将坐标点信息从地图显示坐标系转换为符合WMS服务要求的坐标系。
[0053] 本步骤中,在提取出地图点击事件对应的坐标点信息后,由于地图显示所采用的坐标系与WMS服务要求的坐标系可能存在差异,需调用此前引入的坐标转换库进行坐标转换操作;首先,明确当前地图实例所使用的显示坐标系以及目标WMS服务规定的坐标系,确保转换前后的坐标系参数准确无误;随后,通过坐标转换库提供的转换接口,将提取到的坐标点信息作为输入参数传入,按照预设的坐标系转换规则,对坐标点的数值进行计算与调整,实现从地图显示坐标系到WMS服务要求坐标系的转换;转换完成后,需验证转换后的坐标点信息是否符合WMS服务的格式规范,确保该坐标点能够被WMS服务正确识别与解析,为后续基于该坐标点向WMS服务请求对应地块数据奠定准确的空间位置基础。
[0054] 步骤405:基于转换后的坐标点信息,通过OpenLayers库构建符合WMS标准的请求,并将请求发送至提供WMS服务图层的服务器。
[0055] 本步骤中,在完成坐标点信息从地图显示坐标系到WMS服务要求坐标系的转换后,基于转换后的坐标点信息,借助OpenLayers库构建符合WMS标准的请求;首先,从已创建的WMS服务图层中获取其数据源配置,明确WMS服务的地址、对应的图层名称等关键参数,这些参数是构建合规请求的基础;同时,结合地图当前视图的分辨率信息,以及转换后的坐标点信息,按照WMS服务的标准协议要求,在请求中配置必要的参数,例如坐标点对应的空间范围、请求数据的格式、所涉及的图层标识等,确保请求参数完整且符合WMS服务的交互规范;请求构建完成后,通过OpenLayers库的内置功能,自动将该请求发送至提供WMS服务图层的服务器;这一过程无需手动处理网络请求细节,OpenLayers库会根据配置的服务地址,以标准的HTTP请求方式将构建好的WMS请求传递给服务器,等待服务器响应并返回与该坐标点对应的地块相关数据,为后续获取和展示地块具体信息做好准备。
[0056] 步骤406:接收服务器返回的响应数据,并解析响应数据,以提取目标地块的几何信息与属性信息。
[0057] 本步骤中,将符合WMS标准的请求发送至服务器后,需等待并接收服务器返回的响应数据,服务器会根据请求中携带的转换后坐标点信息、图层标识等参数,返回包含对应地块数据的响应结果;接收响应数据后,首先判断响应状态是否正常,确保数据在传输过程中未出现丢失或错误,若响应状态正常,则进入数据解析环节;解析响应数据时,依据响应数据的格式提取关键信息,一方面是提取目标地块的几何信息,该信息通常包含地块边界的坐标集合,这些坐标集合将用于后续对地块进行可视化标记;另一方面是提取目标地块的属性信息,这类信息涵盖地块的各类关联数据,如地块编号、所属区域、用途类型等业务相关属性;通过对响应数据的完整解析,将几何信息与属性信息分离并整理为便于后续处理的格式,为实现地块信息展示、高亮标记等功能提供数据支撑。
[0058] 步骤407:基于几何信息,调用OpenLayers库的矢量图形绘制接口,以创建与几何信息对应的矢量要素。
[0059] 本步骤中,基于提取到的几何信息,调用OpenLayers库中专门的矢量图形绘制接口来创建对应的矢量要素;首先,根据地块几何信息的类型,选择OpenLayers库中匹配的几何对象类,将提取到的地块边界坐标集合作为参数传入,构建出与地块实际形状一致的几何对象,确保该几何对象能精准还原地块的空间轮廓;接着,将构建好的几何对象关联到该矢量要素中,同时可对矢量要素进行基础配置,如为其设置名称标识等,以便后续对该矢量要素进行管理和识别;通过这一系列操作,借助OpenLayers库的矢量图形绘制能力,将地块的几何信息转化为可视化的矢量要素,为后续在地图上实现地块高亮标记、直观展示地块位置与形状奠定基础。
[0060] 步骤408:设置矢量要素的填充颜色与边框属性,以形成高亮显示效果。
[0061] 本步骤中,在创建好与地块几何信息对应的矢量要素后,为实现地块的高亮显示效果,需通过OpenLayers库提供的样式配置接口,为该矢量要素设置填充颜色与边框属性;首先,定义一个样式实例,并针对矢量要素的填充部分进行配置,选择合适的填充颜色,也可设置颜色的透明度,确保高亮区域既能清晰突出地块范围,又不会完全遮挡底层地图信息,让用户能直观区分高亮地块与周边区域;接着,对矢量要素的边框属性进行设置,包括边框的颜色、宽度等参数,边框颜色需与填充颜色形成一定对比,进一步强化地块的轮廓边界,方便用户清晰识别地块的具体形状;边框宽度则需根据地图显示效果和用户视觉体验进行合理设定,确保边框既醒目又不显得突兀;将配置好的填充颜色与边框属性整合到样式实例中后,通过矢量要素的样式设置方法,将该样式实例绑定到矢量要素上,使矢量要素在地图上渲染时呈现出预设的高亮显示效果,从而让用户能快速定位到点击的目标地块。
[0062] 步骤409:将高亮显示效果添加至地图实例的矢量图层中,以使得与地图点击事件对应的地块在地图实例上呈现高亮状态。
[0063] 本步骤中,在形成高亮显示效果后,需将该高亮矢量要素添加到地图实例的矢量图层中;首先,若地图实例中已存在用于承载高亮要素的矢量图层,可直接获取该图层;若尚未存在,则需基于OpenLayers库创建一个新的矢量图层,并配置合适的层级优先级,确保该矢量图层能覆盖在底图及WMS服务图层之上,使高亮效果清晰可见且不被其他图层遮挡;随后,矢量图层会自动识别并渲染新添加的矢量要素,结合此前设置的填充颜色与边框属性,在地图实例上精准呈现出与地图点击事件对应的地块轮廓及高亮效果;同时,为避免多次点击后出现多个高亮要素叠加干扰的情况,在添加新的高亮矢量要素前,可先检查矢量图层中是否存在历史高亮要素,若存在则将其移除,确保每次点击仅显示当前目标地块的高亮状态,最终实现点击地块在地图实例上清晰、准确的高亮呈现。
[0064] 步骤410:将属性信息与高亮显示的矢量要素进行数据关联,以支持与所述点击需求对应的地块的属性查询与交互操作。
[0065] 本步骤中,借助OpenLayers库中矢量要素的属性存储功能,将地块的属性信息(如地块编号、所属区域、用途类型等)以键值对的形式挂载到对应的矢量要素对象上,使矢量要素不仅具备可视化的几何形态,还携带了完整的业务属性数据,形成图形-属性一体化的矢量要素;通过这种数据关联方式,当用户对地图上高亮显示的地块进行交互操作(如点击查看详情、hover显示简要信息等)时,可直接从高亮矢量要素中读取关联的属性信息,无需再次向服务器发送数据请求,快速响应用户的属性查询需求;同时,这种关联模式也为后续拓展更多交互功能提供了数据基础,例如基于属性筛选地块、根据属性信息触发特定业务逻辑等,确保与点击需求对应的地块在实现高亮可视化的同时,能够高效支持属性查询与各类交互操作,提升地图应用的实用性与用户体验。
[0066] 以上为本申请提出的方法实施例。基于同样的发明构思,本申请实施例还提供了一种WMS地块数据获取设备,其结构如图2所示。
[0067] 图2为本申请实施例提供的一种WMS地块数据获取设备内部结构示意图。如图2所示,设备包括:至少一个处理器201;以及,与至少一个处理器通信连接的存储器202;其中,存储器202存储有可被至少一个处理器执行的指令,指令被至少一个处理器201执行,以使至少一个处理器201能够:通过天地图平台注册开发者账号,以获取天地图API密钥;基于天地图API密钥,引入天地图JavaScript库、OpenLayers库及坐标转换库,以构建具备坐标系转换能力的地图开发环境;基于地图开发环境,创建GIS地图公共组件,并调用OpenLayers库及天地图JavaScript库,以生成地图实例;在地图实例中的WMS服务图层中注册地图点击事件,并在获取地图点击事件后向WMS服务发送请求,以获得与地图点击事件对应的地块的几何信息与属性信息。
[0068] 本申请的一些实施例提供的对应于图1的一种WMS地块数据获取的非易失性计算机存储介质,存储有计算机可执行指令,计算机可执行指令设置为:通过天地图平台注册开发者账号,以获取天地图API密钥;基于天地图API密钥,引入天地图JavaScript库、OpenLayers库及坐标转换库,以构建具备坐标系转换能力的地图开发环境;基于地图开发环境,创建GIS地图公共组件,并调用OpenLayers库及天地图JavaScript库,以生成地图实例;在地图实例中的WMS服务图层中注册地图点击事件,并在获取地图点击事件后向WMS服务发送请求,以获得与地图点击事件对应的地块的几何信息与属性信息。
[0069] 本申请中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于物联网设备和介质实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
[0070] 本申请实施例提供的系统和介质与方法是一一对应的,因此,系统和介质也具有与其对应的方法类似的有益技术效果,由于上面已经对方法的有益技术效果进行了详细说明,因此,这里不再赘述系统和介质的有益技术效果。
[0071] 本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
[0072] 本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
[0073] 这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
[0074] 这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
[0075] 在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入 / 输出接口、网络接口和内存。
[0076] 内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和 / 或非易失性内存等形式,如只读存储器(ROM)或闪存(flashRAM)。内存是计算机可读介质的示例。
[0077] 计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitorymedia),如调制的数据信号和载波。
[0078] 还需要说明的是,术语"包括”、"包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句"包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
[0079] 以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。< / script> < / template>
Claims
1. A method for acquiring WMS land parcel data, characterized in that, The method includes: Register a developer account on the Tianditu platform to obtain the Tianditu API key; Based on the aforementioned Tianditu API key, the Tianditu JavaScript library, OpenLayers library, and coordinate transformation library are introduced to build a map development environment with coordinate system transformation capabilities; Based on the map development environment, a GIS map public component is created, and the OpenLayers library and the Tianditu JavaScript library are called to generate a map instance; wherein, the map instance includes a Tianditu image layer, a Tianditu annotation layer, and a WMS service layer; Register a map click event in the WMS service layer of the map instance, and send a request to the WMS service after obtaining the map click event to obtain the geometric and attribute information of the plot corresponding to the map click event.
2. The WMS land parcel data acquisition method according to claim 1, characterized in that, Register a developer account on the Tianditu platform to obtain the Tianditu API key, which includes: Access the Tianditu platform and complete the registration and authentication process for the developer account; Log in to the verified developer account to access the application management interface and create an application project; In the application project, select the type of map service to be invoked and submit the application configuration; The Tianditu API key is generated based on the application configuration.
3. The method for acquiring WMS land parcel data according to claim 2, characterized in that, Based on the aforementioned Tianditu API key, the Tianditu JavaScript library, OpenLayers library, and coordinate transformation library are introduced to construct a map development environment with coordinate system transformation capabilities, specifically including: Determine the header area in the application project to find the location where the library files are imported; Based on the library file import location, the import code of the Tianditu JavaScript library, the OpenLayers library, and the coordinate transformation library is added via CDN link to complete the import of the Tianditu JavaScript library, the OpenLayers library, and the coordinate transformation library; Start the application project to check for loading error messages of the library files and build a map development environment with coordinate system transformation capabilities.
4. The WMS land parcel data acquisition method according to claim 3, characterized in that, The application project is launched to check for loading error messages for the library files and to build a map development environment with coordinate system transformation capabilities, specifically including: If the loading error message exists, the user is reminded to check whether the CDN link is complete, whether the Tianditu API key is accurate, and / or whether the imported code is written in a standardized manner, until the loading error message no longer exists. If the loading error message is not present, the construction of the map development environment with coordinate system transformation capability is complete.
5. The method for acquiring WMS land parcel data according to claim 3, characterized in that, Based on the aforementioned map development environment, a common GIS map component is created, and the OpenLayers library and the Tianditu JavaScript library are called to generate a map instance, specifically including: Create the GIS map public component in the application project; Initialize the map container in the GIS map public component to generate an initial map instance; Configure the coordinate system, center point coordinates, and initial zoom level of the initial map instance to generate a map view with a specified display range; Based on the Tianditu JavaScript library, the Tianditu image layer is created and added to the map view with a specified display range to generate a map instance containing a base map; Based on the WMS layer interface in the OpenLayers library, the WMS service layer is created and overlaid on the map instance containing the base map to generate the map instance with a multi-layer structure.
6. The method for acquiring WMS land parcel data according to claim 1, characterized in that, Registering map click events in the WMS service layer of the map instance specifically includes: Call the listener interface in the OpenLayers library associated with the map instance; When the listening interface receives a map click event, it extracts the coordinate information of the map click event and sets the response handling function of the map click event to complete the registration of the map click event.
7. A method for acquiring WMS land parcel data according to claim 6, characterized in that, After obtaining the map click event, a request is sent to the WMS service to obtain the geometric and attribute information of the plot corresponding to the map click event, specifically including: In response to the map click event obtained by the listening interface, the response processing function is executed to extract the coordinate point information contained in the click request; The coordinate transformation library is invoked to convert the coordinate point information from the map display coordinate system to a coordinate system that meets the requirements of WMS services; Based on the transformed coordinate point information, a request conforming to the WMS standard is constructed using the OpenLayers library, and the request is sent to the server providing the WMS service layer; The system receives the response data returned by the server and parses the response data to extract the geometric and attribute information of the target plot.
8. The method for acquiring WMS land parcel data according to claim 1, characterized in that, After obtaining the geometric and attribute information of the plot corresponding to the map click event, the method further includes: Based on the geometric information, the vector graphics drawing interface of the OpenLayers library is called to create vector features corresponding to the geometric information; Set the fill color and border attributes of the vector elements to create a highlighted display effect; The highlighting effect is added to the vector layer of the map instance so that the plot corresponding to the map click event is highlighted on the map instance; The attribute information is associated with the highlighted vector features to support attribute query and interactive operations for the plots corresponding to the click request.
9. A WMS land parcel data acquisition device, characterized in that, The device includes: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform a method as described in any one of claims 1-8.
10. A non-volatile computer storage medium for WMS land parcel data acquisition, storing computer-executable instructions, characterized in that, When the computer-executable instructions are executed, they implement a method as described in any one of claims 1-8.