Load Google Maps with current user position in custom widget

Can anyone help with with how, where, and what code to add to load Google maps with the users’ current location (when using Google Maps with Algolia data via a custom map widget)?

Here is my map widget code and below this is the Google Maps getCurrentPosition code which I think is what’s needed(?) though I’ve not been able to write it into the existing custom map widget code.

var customMapWidget = {
  _autocompleteContainer: document.querySelector('#places'),
  _mapContainer: document.querySelector('#map'),
  markers: [],

    // Transform one hit to a Google Maps marker
    _hitToMarker: function(hit) {
      var marker = new google.maps.Marker({
        position: {lat: hit._geoloc.lat, lng: hit._geoloc.lng},
        map: this._map,
        title: hit.SiteName

      var infowindow = new google.maps.InfoWindow({
        content: hit.SiteName

      // Add an info popup when clicking on the marker.
      marker.addListener('click', function() {
        infowindow.open(map, marker);

      return marker;
  _handlePlaceChange: function(place) {
    // https://developers.google.com/maps/documentation/javascript/reference#Autocomplete
    var place = this._autocomplete.getPlace();

    if (place.geometry === undefined) {
      // user did not select any place, see https://developers.google.com/maps/documentation/javascript/reference#Autocomplete
      // events paragraph
      if (place.name === '') {
        // input was cleared

    // see https://developers.google.com/maps/documentation/javascript/reference#PlaceResult
    var latlng = place.geometry.location.toUrlValue();

    // https://www.algolia.com/doc/guides/geo-search/geo-search-overview/#filter-and-sort-around-a-location
      .setQueryParameter('aroundLatLng', latlng)
  init: function(params) {
    this._helper = params.helper;
    this._autocomplete = new google.maps.places.Autocomplete(
        {types: ['geocode'], componentRestrictions: {country: 'au'}});
    this._autocomplete.addListener('place_changed', this._handlePlaceChange.bind(this));
    this._map = new google.maps.Map(this._mapContainer, {zoom: 1, center: new google.maps.LatLng(0, 0)});
  render: function(params) {
    var markers = params.results.hits.map(this._hitToMarker.bind(this));
    var bounds = new google.maps.LatLngBounds();
    markers.forEach(function(marker) {

Google getCurrentPosition code… (Source here)

      infoWindow = new google.maps.InfoWindow;
        // Try HTML5 geolocation. if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = {
              lat: position.coords.latitude,
              lng: position.coords.longitude

            infoWindow.setContent('Location found.');
          }, function() {
            handleLocationError(true, infoWindow, map.getCenter());
        } else {
          // Browser doesn't support Geolocation
          handleLocationError(false, infoWindow, map.getCenter());

@mobilemuster What are you trying to display on the map? It seems like you are firing a search to Algolia but never display the results