vectorTileLayerNormal.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_vectorTileLayerNormal"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  13. <script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, selectId, selectLayerName, vectorLayer,
  17. url = host+"/iserver/services/map-china400/rest/maps/China";
  18. map = L.map('map', {
  19. center: [39.89, 116.43],
  20. maxZoom: 15,
  21. zoom: 1
  22. });
  23. vectorLayer = L.supermap.tiledVectorLayer(url, {
  24. cacheEnabled: true,
  25. returnAttributes: true,
  26. attribution: "Tile Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a></span>"
  27. }).addTo(map);
  28. vectorLayer.on('click', function (evt) {
  29. var id = evt.layer.properties.id;
  30. var layerName = evt.layer.layerName;
  31. clearHighlight();
  32. selectId = id;
  33. selectLayerName = layerName;
  34. var selectStyle = {
  35. fillColor: '#800026',
  36. fillOpacity: 0.5,
  37. stroke: true,
  38. fill: true,
  39. color: 'red',
  40. opacity: 1,
  41. weight: 2
  42. };
  43. vectorLayer.setFeatureStyle(id, layerName, selectStyle);
  44. });
  45. function clearHighlight() {
  46. if (selectId && selectLayerName) {
  47. vectorLayer.resetFeatureStyle(selectId, selectLayerName);
  48. }
  49. selectId = null;
  50. selectLayerName = null;
  51. }
  52. </script>
  53. </body>
  54. </html>