更改传单控制选择器位置

时间:2017-06-16 23:28:47

标签: javascript css-selectors leaflet

有人可以给我一个关于如何更改传单控制选择器位置,将其移出地图内容区域的提示吗?选择器位于here /////////////////////

//create Leaflet control for selector
var selector = L.control({
    position: 'topright'
});

//create select element (with id, so it can be populated later)
selector.onAdd = function (map) {
    var div = L.DomUtil.create('div', 'select');
    div.innerHTML = '<select id="sta_select"><option>(select station)</option></select>';
    return div;
};
selector.addTo(map);

function populateSelect(targetLayer, property, select_id) {
    for (var i in targetLayer._layers) {
        var optionElement = document.createElement("option");
        optionElement.innerHTML = targetLayer._layers[i].feature.properties[property];
        //store layer index in option element's value at. 

1 个答案:

答案 0 :(得分:1)

这是:

http://jsfiddle.net/avn0ph1p/9/

添加的代码是:

$("#sta_select").appendTo("body"); // change parrent from "map" div to body
$("#sta_select").css("position","absolute");
$("#sta_select").css("right","10px");
$("#sta_select").css("top","10px");