Skip to content

Commit

Permalink
Revert "Fix the map box marker event propagation"
Browse files Browse the repository at this point in the history
  • Loading branch information
rdjpalmer committed Mar 16, 2017
1 parent e9d230a commit cbec45c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 84 deletions.
38 changes: 7 additions & 31 deletions components/Map/BaseMap.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,18 @@
}

.map {
composes: fontSmallIi from '../../globals/typography.css';
overflow: hidden;
position: relative;
-webkit-tap-highlight-color: rgba(0, 0, 0 , 0);
}

.map :global(.mapboxgl-canvas-container) {
z-index: var(--z-mapCanvas);
position: absolute;
-webkit-tap-highlight-color: rgba(0,0,0,0);
composes: fontSmallIi from '../../globals/typography.css';
}

.map :global(.mapboxgl-marker-container) {
z-index: var(--z-mapMarker);
position: absolute;
}
.map :global(.mapboxgl-ctrl-bottom-right) { position:absolute; pointer-events:none; z-index:2; }
.map :global(.mapboxgl-ctrl-bottom-right) { right:0; bottom:0; }

/* controls */
.map :global(.mapboxgl-ctrl-bottom-right) {
position: absolute;
pointer-events: none;
z-index: var(--z-mapControls);
}
.map :global(.mapboxgl-ctrl-bottom-right) {
right: 0;
bottom: 0;
}
.map :global(.mapboxgl-ctrl) {
clear: both;
pointer-events: auto
}
.map :global(.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl) {
margin: 0 10px 10px 0;
float: right;
}
.map :global(.mapboxgl-ctrl) { clear:both; pointer-events:auto }
.map :global(.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl) { margin:0 10px 10px 0; float:right; }

/* attribution */
.map :global(.mapboxgl-ctrl.mapboxgl-ctrl-attrib) {
padding: 0 5px;
background-color: rgba(255, 255, 255, .5);
Expand All @@ -49,7 +25,7 @@
text-decoration: none;
}
.map :global(.mapboxgl-ctrl-attrib a):hover {
color: inherit;
color: inherit;
}
.map :global(.mapboxgl-ctrl-attrib .mapbox-improve-map) {
font-weight: bold;
Expand Down
3 changes: 0 additions & 3 deletions globals/z-index.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@
--z-floatingActionBtn: var(--z-6);
--z-stickyNode: var(--z-5);
--z-tooltip: var(--z-3);
--z-mapCanvas: var(--z-1);
--z-mapMarker: var(--z-2);
--z-mapControls: var(--z-3);
}
50 changes: 0 additions & 50 deletions utils/mapboxgl/mapboxgl.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,7 @@
/* global window:true */
import { canUseDOM } from 'exenv';

const mapboxgl = canUseDOM ? require('mapbox-gl/dist/mapbox-gl') : {};

mapboxgl.accessToken = 'pk.eyJ1IjoiYXBwZWFyaGVyZSIsImEiOiJvUlJ0MWxNIn0.8_mzlmxdekKy99luyV4T7w';

const create = (tagName, className, container) => {
if (!canUseDOM) return {};

const el = window.document.createElement(tagName);
if (className) el.className = className;
if (container) container.appendChild(el);
return el;
};

/* eslint-disable no-underscore-dangle */
class MapWithMarkerContainer extends mapboxgl.Map {
_setupContainer() {
super._setupContainer();

const container = this.getContainer();
this.markerContainer = create('div', 'mapboxgl-marker-container', container);
}

getMarkerContainer() {
return this.markerContainer;
}
}

// addTo function taken from version 0.33.0
// https://github.com/mapbox/mapbox-gl-js/blob/adef501c464d51b328bdcdea355008aea9ab8ae1/src/ui/marker.js#L33-L52
class Marker extends mapboxgl.Marker {
/**
* Attaches the marker to a map
* @param {Map} map
* @returns {Marker} `this`
*/
addTo(map) {
this.remove();
this._map = map;
map.getMarkerContainer().appendChild(this._element);
map.on('move', this._update);
map.on('moveend', this._update);
this._update();

this._map.on('click', this._onMapClick);

return this;
}
}
/* eslint-enable no-underscore-dangle */

mapboxgl.Map = MapWithMarkerContainer;
mapboxgl.Marker = Marker;

export default mapboxgl;

0 comments on commit cbec45c

Please sign in to comment.