123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title data-i18n="resources.title_scaleline"></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" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
- <script type="text/javascript">
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var map, layerWorld;
- var url = host + "/iserver/services/map-world/rest/maps/World";
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.Navigation({
- dragPanOptions: {
- enableKinetic: true
- }
- })]
- });
- //初始化比例尺控件类
- scaleline = new SuperMap.Control.ScaleLine();
- //是否使用依地量算,默认为false。推荐地图投影为EPSG:4326时设置为false;使用EPSG:900913时设置为true。为true时,比例值按照当前视图中心的水平线计算。
- scaleline.geodesic = true;
- layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("World", url); //获取图层服务地址
- layerWorld.events.on({"layerInitialized": addLayer});
- //添加地图图层、比例尺控件到map
- function addLayer() {
- map.addLayers([layerWorld]);
- map.addControl(scaleline);
- map.setCenter(new SuperMap.LonLat(118, 40), 6);
- }
- </script>
- </body>
- </html>
|