精品伊人久久大香线蕉,开心久久婷婷综合中文字幕,杏田冲梨,人妻无码aⅴ不卡中文字幕

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
jQuery UI Slider

The jQuery UI slider widget creates a draggable handle that can be configured to return a value based on the handle position. Raster layers in OpenLayers provide a setOpacity method that controls the image opacity and accepts values between 0 (totally transparent) and 1 (totally opaque). A jQuery UI slider widget is a user-friendly way to set layer opacity in an OpenLayers map.

A jQuery UI slider can be created with something like the following markup.

<div id="slider-id">    <div class="ui-slider-handle"></div></div>

To give these elements the slider behavior, you would run the following code.

jQuery("#slider-id").slider();

The jQuery function is also exported under the alias $. In the examples below, you’ll see the use of the $ function. This is entirely equivalent to using the jQuery function.

5.2.1. Using a Slider to Control Layer Opacity

We’ll start with a working example that displays one WMS layer and one vector layer with features from a WFS.

Tasks

  1. Open your text editor and save the following as map.html in the root of your workshop folder:

    <!DOCTYPE html><html>    <head>        <title>My Map</title>        <link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">        <style>            #map-id {                width: 512px;                height: 256px;            }        </style>        <script src="openlayers/lib/OpenLayers.js"></script>    </head>    <body>        <h1>My Map</h1>        <div id="map-id"></div>        <script>            var medford = new OpenLayers.Bounds(                4284890, 253985,                4288865, 257980            );            var map = new OpenLayers.Map("map-id", {                projection: new OpenLayers.Projection("EPSG:2270"),                units: "ft",                maxExtent: medford,                restrictedExtent: medford,                maxResolution: 2.5,                numZoomLevels: 5            });            var base = new OpenLayers.Layer.WMS(                "Medford Streets & Buildings",                "/geoserver/wms",                {layers: "medford"}            );            map.addLayer(base);            var buildings = new OpenLayers.Layer.Vector("Buildings", {                strategies: [new OpenLayers.Strategy.BBOX()],                protocol: new OpenLayers.Protocol.WFS({                    version: "1.1.0",                    url: "/geoserver/wfs",                    featureType: "buildings",                    featureNS: "http://medford.opengeo.org",                    srsName: "EPSG:2270"                })            });            map.addLayer(buildings);            map.zoomToMaxExtent();        </script>    </body></html>
  2. Next we need to pull in the jQuery resources that our widgets will require. Add the following markup to the <head> of your map.html document:

    <link rel="stylesheet" href="jquery-ui/css/smoothness/jquery-ui-1.8.14.custom.css" type="text/css"><script src="jquery-ui/js/jquery-1.5.1.min.js"></script><script src="jquery-ui/js/jquery-ui-1.8.14.custom.min.js"></script>
  3. The slider widget needs some markup to start with. Insert the following in the <body> of your map.html page, just after the map viewport, in order to create a container for the slider:

    <div id="slider-id"><div class="ui-slider-handle"></div>
  4. One bit of preparation before finalizing the code is to style the slider container. In this case, we’ll make the slider as wide as the map and give it some margin. Insert the following style declarations into the <style> element within the <head> of your document:

    #slider-id {    width: 492px;    margin: 10px;}
  5. Having pulled in the required jQuery resources, created some markup for the widget, and given it some style, we’re ready to add the code that creates the slider widget. In the <script> element that contains your map initialization code, insert the following to create the slider widget and set up a listener to change your layer opacity as the slider value changes:

    $("#slider-id").slider({    value: 100,    slide: function(e, ui) {        base.setOpacity(ui.value / 100);    }});
  6. Save your changes to map.html and open the page in your browser: @workshop_url@/map.html

    A map with a slider widget to control layer opacity.

Bonus Task

  1. In the jQuery documentation, find the options for the slider function that allow you to specify a number of incremental steps within the slider range. Experiment with adding discrete intervals to the slider range. Modify the end values of the range to restrict opacity settings.

Having mastered the jQuery UI slider, you’re ready to start working with dialogs.

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
jquery ui的css設(shè)計(jì)
OpenLayers
使用geoserver+openLayers加載google地圖
geoserver開發(fā)
OpenLayers項(xiàng)目完整分析——(二)源代碼總體結(jié)構(gòu)分析-睜眼瞎看-3sN...
基于 jQuery UI 的解鎖驗(yàn)證(代替驗(yàn)證碼)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

主站蜘蛛池模板: 辉南县| 河西区| 平乐县| 中西区| 清远市| 盐亭县| 交口县| 肥城市| 和硕县| 溧阳市| 洛隆县| 梅河口市| 达日县| 忻州市| 武汉市| 彭阳县| 天门市| 阜康市| 陆良县| 宁阳县| 中西区| 高阳县| 万安县| 岫岩| 甘德县| 九江县| 长治县| 井陉县| 道孚县| 井研县| 那曲县| 永安市| 赫章县| 乌兰浩特市| 高唐县| 建始县| 公主岭市| 道孚县| 灵宝市| 阜平县| 莱芜市|