本套件是搭配達康地圖 ( http://api.map.com.tw )
所自訂的地圖控制項
需要引入以下檔案:
- jQuery Lib (最低版本 1.6 以上)
- iScaleBar.js
- iScaleBar.css
初始化建構式
new iScaleBar( map ,options);
map
需要傳入map 參考物件options
初始化選項 (*not required)
註解(移除)原有的達康地圖控制項
//map.addControl ('LargeScaleBar');
*初始化時可不用傳入
mapcanvas
預設值為"map_canvas"type
- "large" 包含刻度尺
- "small" 僅有 "+","-"按鈕.預設值為 "large"
useMouseWheel
是否使用滑鼠滾輪useDarggable
是否使用拖曳功能(jquery ui draggable)mouseWheelPluginUrl
滑鼠滾輪plugin 所在位置 (default: assets/jquery.mousewheel.js)draggablePluginUrl
拖曳功能plugin 所在位置 (default: assets/jquery-ui-draggable.min.js)zoom_gap_min
地圖放大最小值預設為1zoom_gap_max
地圖放大最大值預設為12
- example 1.
直接使用iScalbar
new iScaleBar( map );
- example 2.
設定zoom gap 介於9~12
new iScaleBar( map , { zoom_gap_min : 9, zoom_gap_max : 12 } );
- example 3.
使用小的scalebar (僅有 + - 的按鈕)
new iScaleBar( map , { type : ”small” } );
- example 4.
不使用滑鼠滾輪,拖曳功能
new iScaleBar( map , { useDarggable : false , useMouseWheel : false } );
<!doctype html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Map Scalbar Demo</title> <link rel="stylesheet" href="assets/iScaleBar.css"> <script type = "text/javascript" src='http://code.jquery.com/jquery-1.6.min.js'></script> <script type = "text/javascript" src="assets/iScaleBar.js"></script> <!-- use Trend-go map's API, api and kep need to apply at "http://api.map.com.tw"--> <script type="text/javascript" src="http://api.map.com.tw/js/getAPI.asp?v=1&key=your_api_key"></script> <script> $(function(){ var map; //define map map = new iMap (document.getElementById ("map_canvas")); map.centerMap (new Point (121.52,25.035) ,7 ); //init location //init constructor. new iScaleBar( map ); }); </script> </head > <body> <div id="map_canvas" style="width:750px;height:370px;"></div> </div> </body> </html>
this software is released under WTFPL
Copyright (C) 2013 Justin Wu This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See below for more details. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004