kopia lustrzana https://github.com/OpenDroneMap/WebODM
Added hooks for layersControl in plugins
rodzic
ab094318c3
commit
1470932437
|
@ -8,11 +8,16 @@ const leafletPreCheck = (options) => {
|
|||
assert(options.tiles !== undefined);
|
||||
};
|
||||
|
||||
const layersControlPreCheck = (options) => {
|
||||
assert(options.layersControl !== undefined);
|
||||
leafletPreCheck(options);
|
||||
}
|
||||
|
||||
export default {
|
||||
namespace: "Map",
|
||||
|
||||
endpoints: [
|
||||
["willAddControls", leafletPreCheck],
|
||||
["willAddControls", layersControlPreCheck],
|
||||
["didAddControls", leafletPreCheck],
|
||||
["addActionButton", leafletPreCheck],
|
||||
]
|
||||
|
|
|
@ -206,11 +206,6 @@ class Map extends React.Component {
|
|||
zoomControl: false
|
||||
});
|
||||
|
||||
PluginsAPI.Map.triggerWillAddControls({
|
||||
map: this.map,
|
||||
tiles
|
||||
});
|
||||
|
||||
Leaflet.control.scale({
|
||||
maxWidth: 250,
|
||||
}).addTo(this.map);
|
||||
|
@ -264,7 +259,11 @@ https://a.tile.openstreetmap.org/{z}/{x}/{y}.png
|
|||
baseLayers: this.basemaps
|
||||
}).addTo(this.map);
|
||||
|
||||
this.map.layerControl = this.autolayers;
|
||||
PluginsAPI.Map.triggerWillAddControls({
|
||||
map: this.map,
|
||||
layersControl: this.autolayers,
|
||||
tiles
|
||||
});
|
||||
|
||||
this.map.fitWorld();
|
||||
this.map.attributionControl.setPrefix("");
|
||||
|
|
|
@ -8,7 +8,8 @@ import ElevationMapPanel from './ElevationMapPanel';
|
|||
class ElevationMapButton extends React.Component {
|
||||
static propTypes = {
|
||||
tasks: PropTypes.object.isRequired,
|
||||
map: PropTypes.object.isRequired
|
||||
map: PropTypes.object.isRequired,
|
||||
layersControl: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
constructor(props){
|
||||
|
@ -34,7 +35,7 @@ class ElevationMapButton extends React.Component {
|
|||
<a href="javascript:void(0);"
|
||||
onClick={this.handleOpen}
|
||||
className="leaflet-control-elevationmap-button leaflet-bar-part theme-secondary"></a>
|
||||
<ElevationMapPanel map={this.props.map} isShowed={showPanel} tasks={this.props.tasks} onClose={this.handleClose} />
|
||||
<ElevationMapPanel map={this.props.map} layersControl={this.props.layersControl} isShowed={showPanel} tasks={this.props.tasks} onClose={this.handleClose} />
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ export default L.Control.extend({
|
|||
onAdd: function (map) {
|
||||
var container = L.DomUtil.create('div', 'leaflet-control-elevationmap leaflet-bar leaflet-control');
|
||||
L.DomEvent.disableClickPropagation(container);
|
||||
ReactDOM.render(<ElevationMapButton map={this.options.map} tasks={this.options.tasks} />, container);
|
||||
ReactDOM.render(<ElevationMapButton map={this.options.map} layersControl={this.options.layersControl} tasks={this.options.tasks} />, container);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ export default class ElevationMapPanel extends React.Component {
|
|||
onClose: PropTypes.func.isRequired,
|
||||
tasks: PropTypes.object.isRequired,
|
||||
isShowed: PropTypes.bool.isRequired,
|
||||
map: PropTypes.object.isRequired
|
||||
map: PropTypes.object.isRequired,
|
||||
layersControl: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
constructor(props){
|
||||
|
@ -167,7 +168,7 @@ export default class ElevationMapPanel extends React.Component {
|
|||
}
|
||||
|
||||
addGeoJSONFromURL = (url, cb) => {
|
||||
const { map } = this.props;
|
||||
const { map, layersControl } = this.props;
|
||||
|
||||
$.getJSON(url)
|
||||
.done((geojson) => {
|
||||
|
@ -204,7 +205,7 @@ export default class ElevationMapPanel extends React.Component {
|
|||
|
||||
this.setState({ previewLayer: featureGroup });
|
||||
this.state.previewLayer.addTo(map);
|
||||
map.layerControl.addOverlay(this.state.previewLayer, "Elevation Map");
|
||||
layersControl.addOverlay(this.state.previewLayer, "Elevation Map");
|
||||
|
||||
cb();
|
||||
}catch(e){
|
||||
|
@ -215,11 +216,11 @@ export default class ElevationMapPanel extends React.Component {
|
|||
}
|
||||
|
||||
removePreview = () => {
|
||||
const { map } = this.props;
|
||||
const { map, layersControl } = this.props;
|
||||
|
||||
if (this.state.previewLayer){
|
||||
map.removeLayer(this.state.previewLayer);
|
||||
map.layerControl.removeLayer(this.state.previewLayer);
|
||||
layersControl.removeLayer(this.state.previewLayer);
|
||||
this.setState({previewLayer: null});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@ PluginsAPI.Map.willAddControls([
|
|||
|
||||
// TODO: add support for map view where multiple tasks are available?
|
||||
if (tasks.length === 1){
|
||||
args.map.addControl(new ElevationMap({map: args.map, tasks: tasks}));
|
||||
args.map.addControl(new ElevationMap({map: args.map, layersControl: args.layersControl, tasks: tasks}));
|
||||
}
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue