123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_findLocation"></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, findLocationService, findLocationParameter,
- 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)
- .once("load", function () {
- findLocationProcess();
- });
- function findLocationProcess() {
- //添加设施点
- L.marker([-593.56822512495194, 1675.9256791377206]).addTo(map);
- L.marker([-2358.0414663985171, 2820.35101097629]).addTo(map);
- L.marker([-3647.0074300836109, 2909.4396668115278]).addTo(map);
- L.marker([-5616.5950974905827, 1544.5037476378677]).addTo(map);
- L.marker([-2130.4887600981415, 6623.5972101719526]).addTo(map);
- L.marker([-4504.2328567816048, 5482.4979617984973]).addTo(map);
- L.marker([-1627.6012900626256, 6940.6579024271468]).addTo(map);
- L.marker([-5747.5063918659716, 8215.9188781715948]).addTo(map);
- // 设置设施点的资源供给中心
- var supplyCenterType_FIXEDCENTER = SuperMap.SupplyCenterType.FIXEDCENTER,
- supplyCenterType_NULL = SuperMap.SupplyCenterType.NULL;
- var supplyCenterType_OPTIONALCENTER = SuperMap.SupplyCenterType.OPTIONALCENTER,
- supplyCenters = [new SuperMap.SupplyCenter({
- maxWeight: 500, // 资源供给中心的最大耗费值,必设参数
- nodeID: 139, // 资源供给中心点的结点 ID 号,必设参数
- resourceValue: 100, // 资源供给中心能提供的最大服务量或商品数量,必设参数
- type: supplyCenterType_OPTIONALCENTER //选址分区中资源中心的类型包括固定中心和可选中心两种
- }),
- new SuperMap.SupplyCenter({
- maxWeight: 500,
- nodeID: 1358,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.SupplyCenter({
- maxWeight: 500,
- nodeID: 2972,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.SupplyCenter({
- maxWeight: 500,
- nodeID: 5523,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.SupplyCenter({
- maxWeight: 500,
- nodeID: 1161,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.SupplyCenter({
- maxWeight: 500,
- nodeID: 4337,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.SupplyCenter({
- maxWeight: 500,
- nodeID: 5732,
- resourceValue: 100,
- type: supplyCenterType_NULL
- }),
- new SuperMap.SupplyCenter({
- maxWeight: 500,
- nodeID: 663,
- resourceValue: 100,
- type: supplyCenterType_FIXEDCENTER
- })
- ];
- //创建选址分区分析服务实例
- findLocationService = L.supermap.networkAnalystService(serviceUrl);
- //创建选址分区分析参数实例
- findLocationParameter = new SuperMap.FindLocationParameters({
- // 期望用于最终设施选址的资源供给中心数量,必设字段
- expectedSupplyCenterCount: 8,
- // 是否从中心点开始分配资源。默认为 false
- isFromCenter: false,
- nodeDemandField: "Demand",
- // 转向权值字段的名称
- turnWeightField: "TurnCost",
- // 阻力字段的名称, 必设
- weightName: "length",
- // 资源供给中心集合,必设字段
- supplyCenters: supplyCenters
- });
- //进行查找
- findLocationService.findLocation(findLocationParameter, function (serviceResult) {
- L.geoJSON(serviceResult.result.demandResults, {
- pointToLayer: function (geoJsonPoint, latlng) {
- return L.circleMarker(latlng, {radius: 1, color: "green"});
- }
- }).addTo(map);
- });
- }
- </script>
- </body>
- </html>
|