12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_markerCluster"></title>
- <script type="text/javascript" src="../js/include-web.js"></script>
- </head>
- <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
- <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
- <script type="text/javascript" include="leaflet.markercluster" src="../../dist/leaflet/include-leaflet.js"></script>
- <script type="text/javascript">
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var map, resultLayer, getFeatureBySQLParams,
- dataUrl = host + "/iserver/services/data-DynamicData/rest/data",
- url = host + "/iserver/services/map-china400/rest/maps/China";
- map = L.map('map', {
- preferCanvas: true,
- center: [32, 104],
- maxZoom: 18,
- zoom: 4
- });
- L.supermap.tiledMapLayer(url).addTo(map);
- resultLayer = L.markerClusterGroup({
- spiderfyOnMaxZoom: false,
- showCoverageOnHover: false,
- zoomToBoundsOnClick: false
- });
- getFeatureBySQLParams = new SuperMap.GetFeaturesBySQLParameters({
- queryParameter: new SuperMap.FilterParameter({
- name: "Train@DynamicData",
- attributeFilter: "SmID>100 and SmID < 800"
- }),
- toIndex: -1,
- datasetNames: ["DynamicData:Train"]
- });
- loadMarkerCluster();
- function loadMarkerCluster() {
- L.supermap
- .featureService(dataUrl)
- .getFeaturesBySQL(getFeatureBySQLParams, function (serviceResult) {
- createLayers(serviceResult.result.features);
- });
- }
- function createLayers(result) {
- if (!result || !result.features || result.features.length < 1) {
- return;
- }
- result.features.map(function (feature) {
- var latLng = L.CRS.EPSG3857.unproject(L.point(feature.geometry.coordinates));
- resultLayer.addLayer(L.marker(latLng));
- });
- resultLayer.addTo(map);
- }
- </script>
- </body>
- </html>
|