123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <!--********************************************************************
- * 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>
- <style type="text/css">
- body {
- margin: 0;
- overflow: hidden;
- background: #fff;
- width: 100%;
- height: 100%
- }
- #map {
- position: absolute;
- width: 100%;
- height: 100%;
- }
- #toolbar {
- position: absolute;
- top: 50px;
- right: 10px;
- text-align: center;
- z-index: 100;
- border-radius: 4px;
- }
- </style>
- </head>
- <body>
- <div id="toolbar" class="panel panel-primary">
- <div class='panel-heading'>
- <h5 class='panel-title text-center' data-i18n="resources.text_findLocation"></h5></div>
- <div class='panel-body content'>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.text_analyst"
- onclick="findLocaltion()"/>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.text_input_value_clear"
- onclick="clearElements()"/>
- </div>
- </div>
- <div id="map"></div>
- <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
- <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
- <script>
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var local, map, layer, vectorLayer, markerLayer1,
- markerLayer2,
- style = {
- strokeColor: "#304DBE",
- strokeWidth: 2,
- pointRadius: 2,
- pointerEvents: "visiblePainted",
- fill: true,
- fillColor: "#304DBE"
- },
- url1 = host + "/iserver/services/map-changchun/rest/maps/长春市区图",
- url2 = host + "/iserver/services/transportationanalyst-sample/rest/networkanalyst/RoadNet@Changchun";
- init();
- function init() {
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.ScaleLine(),
- new SuperMap.Control.Zoom(),
- new SuperMap.Control.Navigation({
- dragPanOptions: {
- enableKinetic: true
- }
- })], units: "m"
- });
- map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
- layer = new SuperMap.Layer.TiledDynamicRESTLayer("Changchun", url1, {
- transparent: true,
- cacheEnabled: true
- }, {maxResolution: "auto"});
- layer.events.on({"layerInitialized": addLayer});
- vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
- markerLayer1 = new SuperMap.Layer.Markers("Markers");
- markerLayer2 = new SuperMap.Layer.Markers("Markers");
- var size = new SuperMap.Size(44, 40),
- offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(1675.9256791377206, -593.56822512495194), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(2820.35101097629, -2358.0414663985171), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(2909.4396668115278, -3647.0074300836109), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(1544.5037476378677, -5616.5950974905827), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(6623.5972101719526, -2130.4887600981415), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(5482.4979617984973, -4504.2328567816048), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(6940.6579024271468, -1627.6012900626256), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- markerLayer1.addMarker(new SuperMap.Marker(new SuperMap.LonLat(8215.9188781715948, -5747.5063918659716), new SuperMap.Icon("./images/marker-gold.png", size, offset)));
- }
- function addLayer() {
- map.addLayers([layer, vectorLayer, markerLayer1, markerLayer2]);
- map.setCenter(new SuperMap.LonLat(4503.6240321526, -3861.911472192499), 0);
- }
- function findLocaltion() {
- vectorLayer.removeAllFeatures();
- markerLayer2.clearMarkers();
- var findLocaltionService, parameter, analystParameter, resultSetting,
- supplyCenterType_FIXEDCENTER = SuperMap.REST.SupplyCenterType.FIXEDCENTER,
- supplyCenterType_NULL = SuperMap.REST.SupplyCenterType.NULL;
- supplyCenterType_OPTIONALCENTER = SuperMap.REST.SupplyCenterType.OPTIONALCENTER,
- supplyCenters = [new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 139,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 1358,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 2972,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 5523,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 1161,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 4337,
- resourceValue: 100,
- type: supplyCenterType_OPTIONALCENTER
- }),
- new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 5732,
- resourceValue: 100,
- type: supplyCenterType_NULL
- }),
- new SuperMap.REST.SupplyCenter({
- maxWeight: 500,
- nodeID: 663,
- resourceValue: 100,
- type: supplyCenterType_FIXEDCENTER
- })
- ];
- parameter = new SuperMap.REST.FindLocationParameters({
- expectedSupplyCenterCount: 3,
- isFromCenter: false,
- nodeDemandField: "Demand",
- turnWeightField: "TurnCost",
- weightName: "length",
- supplyCenters: supplyCenters
- });
- findLocaltionService = new SuperMap.REST.FindLocationService(url2, {
- eventListeners: {"processCompleted": processCompleted}
- });
- findLocaltionService.processAsync(parameter);
- }
- function processCompleted(findLocationEventArgs) {
- var result = findLocationEventArgs.result,
- features = [];
- if (result.demandResults) {
- for (var i = 0, demandResults = result.demandResults, len = demandResults.length; i < len; i++) {
- var feature = new SuperMap.Feature.Vector();
- feature.geometry = demandResults[i].geometry;
- feature.style = style;
- features.push(feature);
- }
- }
- vectorLayer.addFeatures(features);
- }
- function clearElements() {
- vectorLayer.removeAllFeatures();
- markerLayer2.clearMarkers();
- }
- </script>
- </body>
- </html>
|