繁体   English   中英

如何使用xpath克隆SVG映射

[英]How to clone an SVG Map Using xpath

我需要复制来自其他网站的svg地图。

例如,这是我要复制svg地图的网站: https://www.alexa.com/siteinfo/google.com : https://www.alexa.com/siteinfo/google.com

这是网站的xpath位置: //*[@id="visitsMap"]

我需要的? 我想将该xpath的结果/帖子复制到我的页面中。

像这样:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("svg").clone().appendTo("body"); }); $svgTemplate = new SimpleXMLElement($svg_data); $svgTemplate->registerXPathNamespace('svg', 'https://www.alexa.com/siteinfo/google.com'); $style = $svgTemplate->xpath('//*[@id="visitsMap"]'); printf("Original style:\\n%s\\n\\n", (string)$style[0]); }); </script> </head> <body> <svg></svg> </body> 

谢谢

使用超级英雄..

 <style> #chartdiv { width: 100%; height: 500px; } </style> <!-- Resources --> <script src="https://www.amcharts.com/lib/3/ammap.js"></script> <script src="https://www.amcharts.com/lib/3/maps/js/worldLow.js"></script> <script src="https://www.amcharts.com/lib/3/themes/light.js"></script> <script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script> <link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" /> <!-- Chart code --> <script> var map = AmCharts.makeChart( "chartdiv", { "type": "map", "theme": "light", "projection": "mercator", "dataProvider": { "map": "worldLow", "areas": [ { "id": "US" } //BY CHANGING THIS<-- ] }, "areasSettings": { "autoZoom": true, "selectedColor": "#CC0000" }, } ); </script> <!-- HTML --> <div id="chartdiv"></div> 

要查看演示: http : //webbatlas.com/google.com

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM