123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_closestFacilitiesService"></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, findClosetFacilitiesService, findClosetFacilitiesParameter, resultLayer,
- baseUrl = host + "/iserver/services/map-changchun/rest/maps/长春市区图",
- serviceUrl = host + "/iserver/services/transportationanalyst-sample/rest/networkanalyst/RoadNet@Changchun";
- 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: [-3600, 4700],
- maxZoom: 18,
- zoom: 2
- });
- L.supermap.tiledMapLayer(baseUrl, {noWrap: true})
- .addTo(map)
- .on('load', function () {
- findClosetFacilitiesProcess();
- });
- function findClosetFacilitiesProcess() {
- //添加设施点
- var marker1 = L.marker([-3500, 2500]).addTo(map);
- marker1.bindPopup(resources.text_facilityPoint1);
- var marker2 = L.marker([-2500, 5500]).addTo(map);
- marker2.bindPopup(resources.text_facilityPoint2);
- var marker3 = L.marker([-4000, 7000]).addTo(map);
- marker3.bindPopup(resources.text_facilityPoint3);
- //添加事件点
- var myIcon = L.icon({
- iconUrl: '../img/marker.png',
- iconSize: [44, 30]
- });
- var marker4 = L.marker([-3700, 5000], {icon: myIcon}).addTo(map);
- marker4.bindPopup(resources.text_input_value_eventPoint);
- //创建最近设施分析服务实例
- findClosetFacilitiesService = L.supermap.networkAnalystService(serviceUrl);
- //创建最近设施分析参数实例
- var resultSetting = new SuperMap.TransportationAnalystResultSetting({
- returnEdgeFeatures: true,
- returnEdgeGeometry: true,
- returnEdgeIDs: true,
- returnNodeFeatures: true,
- returnNodeGeometry: true,
- returnNodeIDs: true,
- returnPathGuides: true,
- returnRoutes: true
- });
- var analystParameter = new SuperMap.TransportationAnalystParameter({
- resultSetting: resultSetting,
- turnWeightField: "TurnCost",
- weightFieldName: "length" //length,time
- });
- findClosetFacilitiesParameter = new SuperMap.FindClosestFacilitiesParameters({
- //事件点,必设参数
- event: L.latLng(-3700, 5000),
- //要查找的设施点数量。默认值为1
- expectFacilityCount: 1,
- //设施点集合,必设
- facilities: [L.latLng(-3500, 2500), L.latLng(-2500, 5500), L.latLng(-4000, 7000)],
- isAnalyzeById: false,
- parameter: analystParameter
- });
- //进行查找
- findClosetFacilitiesService.findClosestFacilities(findClosetFacilitiesParameter, function (serviceResult) {
- var rersult = serviceResult.result;
- rersult.facilityPathList.map(function (result) {
- resultLayer = L.geoJSON(result.route).addTo(map);
- });
- });
- }
- </script>
- </body>
- </html>
|