1、新建map
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'toner'
})
})
],
renderer:"canvas",
target: 'map',
view: new ol.View({
center: ol.proj.transform([100.1138,36.8917], 'EPSG:4326', 'EPSG:3857'),
zoom: 2
})
});
2、删除control
var removeZoomControl = function(map){
var zoom = null;
var pos =-1;
$.each(map.controls,function(index,value){
if(value instanceof ol.control.Zoom){
zoom = value;
pos = index;
return false;
}
});
delete map.controls[pos];
map.editor_map.removeControl(zoom);
};
3、选择feature
var selectClick = new ol.interaction.Select({
condition: ol.events.condition.click
});
mapctx.editor_map.addInteraction(selectClick);
var selected_features = selectClick.getFeatures();
selected_features.on('add', function(event) {
var feature = event.element;
});
map.on("click", function (e) {
mapctx.editor_map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
...
});
});