<commit_before>import React from "react";
//import Marker from './Marker.jsx';
// import PlurbBlob from 'material-ui/maps/add-location';
import { connect } from 'react-redux';
import { updateMapBounds, getPlurbs } from '../../ACTIONS.jsx';

class GoogleMap extends React.Component {

  constructor(props) {
    super(props);
  }
  
  // Once DOM node has rendered
  componentDidMount(rootNode) {
    let mapOptions = {
      center: {lat: 38.91, lng: -77.04},
      zoom: 6,
    },

    // initialize map center on Washington, DC
    map = new google.maps.Map(document.getElementById('map'), mapOptions);
    
    // re-center map on user
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        let pos = {
          lat: position.coords.latitude,
          lng: position.coords.longitude
        };
        map.setCenter(pos);
      }, function() {
        handleLocationError(true);
      });
    } else {
      // Browser doesn't support Geolocation
      handleLocationError(false);
    }

    function handleLocationError(browserHasGeolocation) {
      if(browserHasGeolocation) {
        console.log("Looks like the browser blocked geolocation");
        map.setCenter({lat: 38.91, lng: -77.04});
      } else {
        console.log("This browser does NOT support geolocation");
        map.setCenter({lat: 38.91, lng: -77.04});
      }
    }

    // When user pauses map movement, updates new bounds
    map.addListener('idle', () => {
      let newBounds = map.getBounds();
      
      let Lats = newBounds.H;
      let Lngs = newBounds.j;
            
      let currentBounds = {
        mapBounds: {
          maxLat: +Lats.j.toFixed(2),
          maxLng: +Lngs.H.toFixed(2),
          minLat: +Lats.H.toFixed(2),
          minLng: +Lngs.j.toFixed(2)   
        }
      }
      
      // update bounds on store, then re-fetch plurbs
      this.props.dispatch(updateMapBounds(currentBounds))
      this.props.dispatch(getPlurbs(currentBounds))
      
      // populate plurbs on map
      this.props.plurbs.map((plurb) => {
        new google.maps.Marker({
          position: {lat: plurb.lat, lng: plurb.long},
          map: map,
          icon: "http://map.karaliki.ru/css/markbig.png"
        });
      });
    });
  }

  render() {
    return (
      <div id='map' className='map-gic' style={{ width: '50%', height:'600px', "opacity":'.90' }}></div>
    );
  }
}

// map the portion of the state tree desired
const mapStateToProps = (store) => {
  return {
    mapBounds: store.pluribusReducer.mapBounds,
    plurbs: store.pluribusReducer.plurbs
  };
};

// export map;

// connect the desired state to the relevant component
export default connect(mapStateToProps)(GoogleMap);
<commit_msg>(refactor) Include selected topic in plurbs query<commit_after>import React from "react";
//import Marker from './Marker.jsx';
// import PlurbBlob from 'material-ui/maps/add-location';
import { connect } from 'react-redux';
import { updateMapBounds, getPlurbs } from '../../ACTIONS.jsx';

class GoogleMap extends React.Component {

  constructor(props) {
    super(props);
  }
  
  // Once DOM node has rendered
  componentDidMount(rootNode) {
    let mapOptions = {
      center: {lat: 38.91, lng: -77.04},
      zoom: 6,
    },

    // initialize map center on Washington, DC
    map = new google.maps.Map(document.getElementById('map'), mapOptions);
    
    // re-center map on user
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        let pos = {
          lat: position.coords.latitude,
          lng: position.coords.longitude
        };
        map.setCenter(pos);
      }, function() {
        handleLocationError(true);
      });
    } else {
      // Browser doesn't support Geolocation
      handleLocationError(false);
    }

    function handleLocationError(browserHasGeolocation) {
      if(browserHasGeolocation) {
        console.log("Looks like the browser blocked geolocation");
        map.setCenter({lat: 38.91, lng: -77.04});
      } else {
        console.log("This browser does NOT support geolocation");
        map.setCenter({lat: 38.91, lng: -77.04});
      }
    }

    // When user pauses map movement, updates new bounds
    map.addListener('idle', () => {
      let newBounds = map.getBounds();
      
      let Lats = newBounds.H;
      let Lngs = newBounds.j;
            
      let query = {
        mapBounds: {
          maxLat: +Lats.j.toFixed(2),
          maxLng: +Lngs.H.toFixed(2),
          minLat: +Lats.H.toFixed(2),
          minLng: +Lngs.j.toFixed(2)   
        }
        topicId: this.props.currentTopicId
      }
      
      // update bounds on store, then re-fetch plurbs
      this.props.dispatch(updateMapBounds(currentBounds))
      this.props.dispatch(getPlurbs(query))
      
      // populate plurbs on map
      this.props.plurbs.map((plurb) => {
        new google.maps.Marker({
          position: {lat: plurb.lat, lng: plurb.long},
          map: map,
          icon: "http://map.karaliki.ru/css/markbig.png"
        });
      });
    });
  }

  render() {
    return (
      <div id='map' className='map-gic' style={{ width: '50%', height:'600px', "opacity":'.90' }}></div>
    );
  }
}

// map the portion of the state tree desired
const mapStateToProps = (store) => {
  return {
    mapBounds: store.pluribusReducer.mapBounds,
    plurbs: store.pluribusReducer.plurbs,
    topicId: store.pluribusReducer.topicId
  };
};

// export map;

// connect the desired state to the relevant component
export default connect(mapStateToProps)(GoogleMap);

{'fraction_non_alphanumeric': 0.13360611990748977, 'fraction_numerical': 0.012809108699519659, 'mean_word_length': 2.3524150268336315, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6592018', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1763, 'n_words': 394}