02_getFeatureByIDs.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_getFeatureByIDs"></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, resultLayer,
  17. baseUrl = host + "/iserver/services/map-world/rest/maps/World",
  18. url = host + "/iserver/services/data-world/rest/data";
  19. map = L.map('map', {
  20. preferCanvas: true,
  21. crs: L.CRS.EPSG4326,
  22. center: [20, 80],
  23. maxZoom: 18,
  24. zoom: 2
  25. });
  26. L.supermap.tiledMapLayer(baseUrl).addTo(map);
  27. query();
  28. function query() {
  29. var idsParam = new SuperMap.GetFeaturesByIDsParameters({
  30. IDs: [246, 247],
  31. datasetNames: ["World:Countries"]
  32. });
  33. L.supermap
  34. .featureService(url)
  35. .getFeaturesByIDs(idsParam, function (serviceResult) {
  36. resultLayer = L.geoJSON(serviceResult.result.features, {
  37. onEachFeature: function (feature, layer) {
  38. layer.bindPopup("ID: " + feature.properties.SMID +
  39. "<br>" + resources.text_country + ":" + feature.properties.COUNTRY);
  40. }
  41. }).addTo(map);
  42. });
  43. }
  44. </script>
  45. </body>
  46. </html>