123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_routeLocatorLine"></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" src="../../dist/leaflet/include-leaflet.js"></script>
- <script type="text/javascript">
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var map, queryBySQLParams, queryBySQLService, resultLayer,
- pointsList, routeLine, routeLocatorParameters_line, routeLocatorService,
- baseUrl = host + "/iserver/services/map-changchun/rest/maps/长春市区图",
- serviceUrl = host + "/iserver/services/spatialanalyst-changchun/restjsr/spatialanalyst";
- map = L.map('map', {
- crs: L.CRS.NonEarthCRS({
- bounds: L.bounds([48.4, -7668.25], [8958.85, -55.58]),
- origin: L.point(48.4, -55.58)
- }),
- center: [-3861.91, 4503.62],
- maxZoom: 18,
- zoom: 2
- });
- L.supermap.tiledMapLayer(baseUrl, {noWrap: true}).addTo(map);
- routeCalculateMeasureProcess();
- function routeCalculateMeasureProcess() {
- //通过SQL查询的方法建立路由,并添加到地图上
- queryBySQLService = L.supermap.queryService(baseUrl);
- queryBySQLParams = new SuperMap.QueryBySQLParameters({
- queryParams: [
- new SuperMap.FilterParameter({
- name: "RouteDT_road@Changchun",
- attributeFilter: "RouteID=1690"
- })
- ]
- });
- queryBySQLService.queryBySQL(queryBySQLParams, function (SQLQueryServiceResult) {
- var result = SQLQueryServiceResult.result;
- if (result && result.recordsets && result.recordsets[0].features) {
- var resultFeatures = result.recordsets[0].features;
- resultLayer = L.geoJSON(resultFeatures, {color: "red"}).addTo(map);
- //将形成路由的点提出来,为了构造下面里程定线服务参数的sourceRoute
- pointsList = [];
- var routeObj = resultFeatures.features[0].geometry.coordinates[0];
- for (var i = 0; i < routeObj.length; i++) {
- pointsList.push([routeObj[i][1], routeObj[i][0], routeObj[i][2]])
- }
- routeLine = L.polyline(pointsList);
- //里程定线服务
- routeLocatorParameters_line = new SuperMap.RouteLocatorParameters({
- "sourceRoute": routeLine,
- "type": "LINE",
- "startMeasure": 10,
- "endMeasure": 800,
- "isIgnoreGap": true
- });
- routeLocatorService = L.supermap.spatialAnalystService(serviceUrl);
- routeLocatorService.routeLocate(routeLocatorParameters_line, function (routeLocatorServiceResult) {
- if (routeLocatorServiceResult.result && routeLocatorServiceResult.result.resultGeometry) {
- L.geoJSON(routeLocatorServiceResult.result.resultGeometry).addTo(map);
- } else {
- alert(routeLocatorServiceResult.error.errorMsg);
- }
- });
- } else {
- alert(SQLQueryServiceResult.error.errorMsg);
- }
- });
- }
- </script>
- </body>
- </html>
|