OpenLayers OpenLayers

Changeset 9757

Show
Ignore:
Timestamp:
10/24/09 00:36:34 (5 months ago)
Author:
ahocevar
Message:

added Graticule control and Util.getFormattedLonLat function. Thanks madair for this excellent patch. p=madair, r=me (closes #1083)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers.js

    r9734 r9757  
    169169            "OpenLayers/Control/Measure.js", 
    170170            "OpenLayers/Control/WMSGetFeatureInfo.js", 
     171            "OpenLayers/Control/Graticule.js", 
    171172            "OpenLayers/Geometry.js", 
    172173            "OpenLayers/Geometry/Rectangle.js", 
  • trunk/openlayers/lib/OpenLayers/Lang/en.js

    r9583 r9757  
    8282 
    8383    'scale': "Scale = 1 : ${scaleDenom}", 
     84     
     85    //labels for the graticule control 
     86    'W': 'W', 
     87    'E': 'E', 
     88    'N': 'N', 
     89    'S': 'S', 
    8490 
    8591    // console message 
  • trunk/openlayers/lib/OpenLayers/Util.js

    r9730 r9757  
    959959                    url.indexOf('#') : url.length; 
    960960        paramsString = url.substring(start, end); 
     961    } else { 
     962        paramsString = url; 
    961963    } 
    962964         
     
    16431645    return scrollbarWidth; 
    16441646}; 
     1647 
     1648/** 
     1649 * APIFunction: getFormattedLonLat 
     1650 * This function will return latitude or longitude value formatted as  
     1651 * 
     1652 * Parameters: 
     1653 * coordinate - {Float} the coordinate value to be formatted 
     1654 * axis - {String} value of either 'lat' or 'lon' to indicate which axis is to 
     1655 *          to be formatted (default = lat) 
     1656 * dmsOption - {String} specify the precision of the output can be one of: 
     1657 *           'dms' show degrees minutes and seconds 
     1658 *           'dm' show only degrees and minutes 
     1659 *           'd' show only degrees 
     1660 *  
     1661 * Returns: 
     1662 * {String} the coordinate value formatted as a string 
     1663 */ 
     1664OpenLayers.Util.getFormattedLonLat = function(coordinate, axis, dmsOption) { 
     1665    if (!dmsOption) { 
     1666        dmsOption = 'dms';    //default to show degree, minutes, seconds 
     1667    } 
     1668    var abscoordinate = Math.abs(coordinate) 
     1669    var coordinatedegrees = Math.floor(abscoordinate); 
     1670 
     1671    var coordinateminutes = (abscoordinate - coordinatedegrees)/(1/60); 
     1672    var tempcoordinateminutes = coordinateminutes; 
     1673    coordinateminutes = Math.floor(coordinateminutes); 
     1674    var coordinateseconds = (tempcoordinateminutes - coordinateminutes)/(1/60); 
     1675    coordinateseconds =  Math.round(coordinateseconds*10); 
     1676    coordinateseconds /= 10; 
     1677 
     1678    if( coordinatedegrees < 10 ) { 
     1679        coordinatedegrees = "0" + coordinatedegrees; 
     1680    } 
     1681    var str = coordinatedegrees + " ";  //get degree symbol here somehow for SVG/VML labelling 
     1682 
     1683    if (dmsOption.indexOf('dm') >= 0) { 
     1684        if( coordinateminutes < 10 ) { 
     1685            coordinateminutes = "0" + coordinateminutes; 
     1686        } 
     1687        str += coordinateminutes + "'"; 
     1688   
     1689        if (dmsOption.indexOf('dms') >= 0) { 
     1690            if( coordinateseconds < 10 ) { 
     1691                coordinateseconds = "0" + coordinateseconds; 
     1692            } 
     1693            str += coordinateseconds + '"'; 
     1694        } 
     1695    } 
     1696     
     1697    if (axis == "lon") { 
     1698        str += coordinate < 0 ? OpenLayers.i18n("W") : OpenLayers.i18n("E"); 
     1699    } else { 
     1700        str += coordinate < 0 ? OpenLayers.i18n("S") : OpenLayers.i18n("N"); 
     1701    } 
     1702    return str; 
     1703}; 
     1704 
  • trunk/openlayers/tests/list-tests.html

    r9734 r9757  
    1616    <li>Control/DrawFeature.html</li> 
    1717    <li>Control/GetFeature.html</li> 
     18    <li>Control/Graticule.html</li> 
    1819    <li>Control/KeyboardDefaults.html</li> 
    1920    <li>Control/LayerSwitcher.html</li>