zoukankan      html  css  js  c++  java
  • openlayers常用操作

    1.坐标转换

    根据当前坐标系与目标坐标系进行转换
    ol.proj.transform(coordinate, source, destination);  //coordinate:数组;source:当前坐标编码;destination:目标坐标编码
    从经纬度转化到指定坐标系
    ol.proj.fromLonLat(coordinate, opt_projection)
    从某坐标转经纬度
    ol.proj.toLonLat(coordinate, opt_projection)
    从源投影变换到目标投影
    ol.proj.transformExtent(extent,source,destination)

    2.常用样式

    var style = new ol.style.Style({
        stroke: new ol.style.Stroke({
            color: 'magenta',
             2
        }),
        fill: new ol.style.Fill({
            color: 'magenta'
        }),
        image: new ol.style.Circle({
            radius: 10,
            fill: null,
            stroke: new ol.style.Stroke({
                color: 'magenta'
            })
        }),
        text: new ol.style.Text({
            font: '12px Calibri,sans-serif',
            text: text,
            fill: new ol.style.Fill({
                color: '#000'
            }),
            stroke: new ol.style.Stroke({
                color: '#f00',
                 3
            })
        })
    })

    3.分级设置样式

    var vectorLayer = new ol.layer.Vector({
        source: new ol.source.Vector({
           url: 'https://openlayers.org/en/v4.1.1/examples/data/geojson/countries.geojson',
          format: new ol.format.GeoJSON()
        }),
        style: function(feature, resolution) {
           style.getText().setText(resolution < 5000 ? feature.get('name') : '');
           return style;
        }
    });        
  • 相关阅读:
    【原创】Java与数据结构(上篇:排序算法)
    【九度OJ】题目1084:整数拆分
    kaixin001接入
    Facebook接入(下)
    svn手册摘录
    Facebook接入(上)
    使用mysqldb从数据库中导出xml
    使用cmd模块,让脚本更舒服些
    django 的简单测试
    python字符串替换
  • 原文地址:https://www.cnblogs.com/ytwy/p/6893783.html
Copyright © 2011-2022 走看看