Skip to content

Commit

Permalink
Fixes issue #2743
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanulde committed Jun 16, 2015
1 parent eaba1b9 commit a5252b2
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions src/plugins/deps/geomap-lib.js
Expand Up @@ -1026,6 +1026,7 @@ var componentName = "wb-geomap",
addBasemapData = function( geomap, opts ) {
var basemap = opts.basemap,
hasBasemap = basemap && basemap.length !== 0,
controls = opts.useMapControls ? [ new OpenLayers.Control.Navigation( { zoomWheelEnabled: true } ) ] : [],
mapOptions, mapOpts, aspectRatio, keys;

if ( hasBasemap ) {
Expand Down Expand Up @@ -1064,11 +1065,7 @@ var componentName = "wb-geomap",
aspectRatio = mapOptions.aspectRatio === undefined ? 0.8 : mapOptions.aspectRatio;
geomap.gmap.height( geomap.gmap.width() * mapOptions.aspectRatio );

geomap.map = new OpenLayers.Map( geomap.gmap.attr( "id" ), $.extend( opts.config, mapOptions ) );

// Initialize control to []. If not, all maps share the same
// set of controls. This maybe a OpenLayers bug
geomap.map.controls = [];
geomap.map = new OpenLayers.Map( geomap.gmap.attr( "id" ), $.extend( opts.config, mapOptions, { controls: controls } ) );

// Check to see if a base map has been configured. If not add the
// default base map (the Canada Transportation Base Map (CBMT))
Expand Down Expand Up @@ -1294,14 +1291,7 @@ var componentName = "wb-geomap",
} ),
eventListeners: {
featuresadded: function( evt ) {
onFeaturesAdded(
geomap,
$table,
evt,
layer.zoom,
layer.datatable,
opts.useMapControls
);
onFeaturesAdded( geomap, $table, evt, layer.zoom, layer.datatable, opts.useMapControls );
if ( geomap.overlaysLoading[ layerTitle ] ) {
onLoadEnd( geomap );
}
Expand Down Expand Up @@ -1789,12 +1779,7 @@ var componentName = "wb-geomap",
features = layer.features;
featuresLen = features.length;
for ( k = 0; k !== featuresLen; k += 1 ) {
onTabularFeaturesAdded(
geomap,
features[ k ],
zoom,
useMapControls
);
onTabularFeaturesAdded( geomap, features[ k ], zoom, useMapControls );
}
}
}
Expand All @@ -1815,9 +1800,8 @@ var componentName = "wb-geomap",
scaleLineDiv.setAttribute( "title", i18nScaleLine );
}

map.addControl( new OpenLayers.Control.Navigation( { zoomWheelEnabled: true } ) );
map.addControl( new OpenLayers.Control.KeyboardDefaults() );
map.getControlsByClass( "OpenLayers.Control.KeyboardDefaults" )[ 0 ].deactivate();
//map.addControl( new OpenLayers.Control.Navigation( { zoomWheelEnabled: true } ) );
map.addControl( new OpenLayers.Control.KeyboardDefaults( { autoActivate: false } ) );

// Add the map div to the tabbing order
$mapDiv.attr( {
Expand Down Expand Up @@ -1931,7 +1915,7 @@ var componentName = "wb-geomap",
projMap = geomap.map.getProjectionObject();

// Global variable
geomap.selectControl = new OpenLayers.Control.SelectFeature();
//geomap.selectControl = new OpenLayers.Control.SelectFeature();

// Add layer holder
createLayerHolder( geomap, opts.useTab );
Expand Down Expand Up @@ -1988,21 +1972,29 @@ var componentName = "wb-geomap",
var type = event.type,
target = event.currentTarget.className.indexOf( "wb-geomap-map" ) === -1 ?
event.currentTarget.parentElement : event.currentTarget,
keyboardDefaults = "OpenLayers.Control.KeyboardDefaults",
navigation = "OpenLayers.Control.Navigation",
keyboardDefaults = map.getControlsByClass( "OpenLayers.Control.KeyboardDefaults" )[ 0 ],
navigation = map.getControlsByClass( "OpenLayers.Control.Navigation" )[ 0 ],
isActive;

if ( map ) {
isActive = target.className.indexOf( "active" );
if ( type === "mouseover" || type === "focusin" ) {
if ( isActive ) {
map.getControlsByClass( keyboardDefaults )[ 0 ].activate();
map.getControlsByClass( navigation )[ 0 ].activate();
if ( keyboardDefaults ) {
keyboardDefaults.activate();
}
if ( navigation ) {
navigation.activate();
}
$( target ).addClass( "active" );
}
} else if ( isActive > 0 ) {
map.getControlsByClass( navigation )[ 0 ].deactivate();
map.getControlsByClass( keyboardDefaults )[ 0 ].deactivate();
if ( navigation ) {
navigation.deactivate();
}
if ( keyboardDefaults ) {
keyboardDefaults.deactivate();
}
$( target ).removeClass( "active" );
}
}
Expand Down

0 comments on commit a5252b2

Please sign in to comment.