我想要一个常量的绝对值,常量类型是CLLocationDegrees

时间:2015-08-18 07:21:35

标签: swift

我不知道如何解决问题,我在工厂遇到错误:一行上的连续陈述必须用';'

分隔
$('#mapsmaps').highcharts('Map', {
        title : {
            text : 'City Lived',  
            style: {
            color: '#008bff'
            }
        },

        subtitle : {
            text : ''
        },        
        legend: {
            title: {
                text: ' ',
                style: {
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
                }
            },
            floating: true,
            valueDecimals: 0,
            valueSuffix: '',
            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || 'rgba(255, 255, 255, 0.85)',
            symbolRadius: 0,
            symbolHeight: 10,

           },

        mapNavigation: {
            enabled: false,
            buttonOptions: {
                verticalAlign: 'bottom'
            }
        },

        tooltip: {
           // backgroundColor: 'none',
            // borderWidth: 0,
            // shadow: false,
            useHTML: true,
            padding: 0,
            pointFormat: '<span class="f32"></span>'
                + ' {point.name}'
        },
        colorAxis: { 
            dataClasses: [{
                from: 1,
                to: 1000,
                color: "#5FA08F"
            }, {
                from: 1000,
                to: 2000,
                color: "#82A970"
            }, {
                from: 2000,
                to: 3000,
                color: "#E5AF47"
            }, {
                from: 3000,
                to: 4000,
                color: "#EC8A37"
            }, {
                from: 4000,
                to: 5000,
                color: "#F55126"
            }, {
                from: 5000,
                color: "#F30505"
            }]
        },

        series : [{
            data : data,
            mapData: Highcharts.maps['countries/en/en-all'],
            joinBy: 'hc-key',
            name: 'City',
            states: {
                hover: {
                    color: '#BADA55'
                }
            },
            animation: {
                duration: 1000
            },
            dataLabels: {
                enabled: false,
                format: '{point.name}'
            }

        }],
            navigation: {
                buttonOptions: {
                    enabled: false
                }
            }
        });
      }

2 个答案:

答案 0 :(得分:0)

使用全局函数abs()

/// Return the absolute value of `x`.
///
/// Concrete instances of `SignedNumberType` can specialize this
/// function by conforming to `AbsoluteValuable`.
func abs<T : SignedNumberType>(x: T) -> T

所以:

let absoluteValueOfLatitude = abs(latitude)
let absoluteValueOfLongitude = abs(longitude)

答案 1 :(得分:0)

啊哈,问题是您输入了不同相等的运算符。

// odd equal operator
let absoluteValueOfLatitude = fabs(latitude)

// correct equal operator
let absoluteValueOfLatitude = fabs(latitude) 

// notice the difference with these two equal operator (= & =)