{"id":53351,"date":"2024-12-03T09:00:09","date_gmt":"2024-12-03T01:00:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53351\/"},"modified":"2024-12-03T09:00:09","modified_gmt":"2024-12-03T01:00:09","slug":"openlayers-%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-ol-ext-%e5%ae%9e%e7%8e%b0%e5%9b%be%e6%a1%88%e5%a1%ab%e5%85%85%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53351\/","title":{"rendered":"OpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>OpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u6211\u4eec\u53c8\u89c1\u9762\u4e86\u554a~\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aOpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f\u300b<\/span>\u7684\u5185\u5bb9\u4e2d\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u3002\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u77e5\u8bc6\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\uff0c\u4ee5\u540e\u4f1a\u7ed9\u5927\u5bb6\u5e26\u6765\u66f4\u591a<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u6587\u7ae0\uff0c\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u8fdb\u6b65\uff01\u4e0b\u9762\u5c31\u5f00\u59cb\u672c\u6587\u7684\u6b63\u5f0f\u5185\u5bb9~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241129\/17328707036749822f7243f.jpg\" class=\"aligncenter\" title=\"OpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f\u63d2\u56fe\" alt=\"OpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\u6548\u679c<\/strong><\/p>\n<p>\u60f3\u8981\u5728 openlayers \u4e2d\u4f7f\u7528\u56fe\u6848\u586b\u5145\u6548\u679c\uff0c\u53ef\u4ee5\u501f\u52a9 ol-ext \u5e93\u3002\u4e0b\u9762\u6765\u4e00\u6b65\u6b65\u4ecb\u7ecd\u5982\u4f55\u5b9e\u73b0\uff1a<\/p>\n<ol>\n<li><strong>\u786e\u8ba4\u5df2\u5b89\u88c5 ol-ext<\/strong><\/li>\n<\/ol>\n<p>\u786e\u4fdd\u5df2\u901a\u8fc7\u547d\u4ee4 npm install &#8211;save ol-ext \u5b89\u88c5\u597d ol-ext \u5e93\u3002<\/p>\n<ol>\n<li><strong>\u4ece ol-ext \u5bfc\u5165 fillpattern<\/strong><\/li>\n<\/ol>\n<p>\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528 import \u5bfc\u5165 fillpattern \u7c7b\uff1a<\/p>\n<pre>import  fillpattern  from 'ol-ext\/style\/fillpattern';<\/pre>\n<ol>\n<li><strong>\u914d\u7f6e\u56fe\u6848\u586b\u5145<\/strong><\/li>\n<\/ol>\n<p>\u521b\u5efa\u56fe\u6848\u586b\u5145\u5bf9\u8c61\uff0c\u5e76\u6307\u5b9a\u8981\u4f7f\u7528\u7684\u56fe\u6848\u3001\u989c\u8272\u548c\u95f4\u8ddd\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>const fillpattern = new fillpattern({\n  src: 'path\/to\/pattern.png',\n  color: 'rgba(255, 0, 0, 1)',\n  spacing: 5\n});<\/pre>\n<ol>\n<li><strong>\u5e94\u7528\u586b\u5145<\/strong><\/li>\n<\/ol>\n<p>\u5c06\u56fe\u6848\u586b\u5145\u5e94\u7528\u4e8e\u8981\u7d20\u6837\u5f0f\uff1a<\/p>\n<pre>const style = new Style({\n  fill: fillPattern\n});<\/pre>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aOpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5168\u9762\u89e3\u6790Windows 10\uff1a\u64cd\u4f5c\u7cfb\u7edf\u7684\u4f18\u52bf\u4e0e\u4f7f\u7528\u6280\u5de7\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>OpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f \u5927\u5bb6\u597d\uff0c\u6211\u4eec\u53c8\u89c1\u9762\u4e86\u554a~\u672c\u6587\u300aOpenLayers \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\uff1f\u300b\u7684\u5185\u5bb9\u4e2d\u5c06\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\u3002\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\uff0c\u4ee5\u540e\u4f1a\u7ed9\u5927\u5bb6\u5e26\u6765\u66f4\u591a\u6587\u7ae0\u76f8\u5173\u6587\u7ae0\uff0c\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u8fdb\u6b65\uff01\u4e0b\u9762\u5c31\u5f00\u59cb\u672c\u6587\u7684\u6b63\u5f0f\u5185\u5bb9~ \u5982\u4f55\u4f7f\u7528 ol-ext \u5b9e\u73b0\u56fe\u6848\u586b\u5145\u6548\u679c \u60f3\u8981\u5728 openlayers \u4e2d\u4f7f\u7528\u56fe\u6848\u586b\u5145\u6548\u679c\uff0c\u53ef\u4ee5\u501f\u52a9 ol-ext \u5e93\u3002\u4e0b\u9762\u6765\u4e00\u6b65\u6b65\u4ecb\u7ecd\u5982\u4f55\u5b9e\u73b0\uff1a \u786e\u8ba4\u5df2\u5b89\u88c5 ol-ext \u786e\u4fdd\u5df2\u901a\u8fc7\u547d\u4ee4 npm install &#8211;save ol-ext \u5b89\u88c5\u597d ol-ext \u5e93\u3002 \u4ece ol-ext \u5bfc\u5165 fillpattern \u5728\u4ee3\u7801\u4e2d\u4f7f\u7528 import \u5bfc\u5165 fillpattern \u7c7b\uff1a import fillpattern from &#8216;ol-ext\/style\/fillpattern&#8217;; \u914d\u7f6e\u56fe\u6848\u586b\u5145 \u521b\u5efa\u56fe\u6848\u586b\u5145\u5bf9\u8c61\uff0c\u5e76\u6307\u5b9a\u8981\u4f7f\u7528\u7684\u56fe\u6848\u3001\u989c\u8272\u548c\u95f4\u8ddd\u3002\u4f8b\u5982\uff1a const fillpattern = new fillpattern({ src: &#8216;path\/to\/pattern.png&#8217;, color: &#8216;rgba(255, 0, 0, 1)&#8217;, spacing: 5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53351","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53351"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53351\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}