How to use the google-map-react/utils.fitBounds function in google-map-react

To help you get started, we’ve selected a few google-map-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deens-com / frontend / src / libs / location.js View on Github external
const fitBoundsFixed = (bounds, ...args) => {
  // https://github.com/google-map-react/google-map-react/issues/207
  const { center, zoom } = fitBounds(bounds, ...args);
  if (zoom === 0) {
    const newBounds = bounds;
    newBounds.sw.lat += 0.0000001;
    newBounds.sw.lng -= 0.0000001;
    const fixedData = fitBounds(newBounds, ...args);
    return { center: fixedData.center, zoom: 14 };
  }
  return { center, zoom };
};
github deens-com / frontend / src / libs / location.js View on Github external
const fitBoundsFixed = (bounds, ...args) => {
  // https://github.com/google-map-react/google-map-react/issues/207
  const { center, zoom } = fitBounds(bounds, ...args);
  if (zoom === 0) {
    const newBounds = bounds;
    newBounds.sw.lat += 0.0000001;
    newBounds.sw.lng -= 0.0000001;
    const fixedData = fitBounds(newBounds, ...args);
    return { center: fixedData.center, zoom: 14 };
  }
  return { center, zoom };
};
github hasura / graphql-engine / community / sample-apps / realtime-location-tracking / src / App / MapContainer.js View on Github external
render() {
    const size = {
      width: 320, // map width in pixels
      height: 400, // map height in pixels
    };
    const {center, zoom} = fitBounds(bounds, size);
    return (
      <div style="{{height:">
         
          
      </div>
github brandingbrand / flagship / packages / fslocator / src / components / MapView.web.tsx View on Github external
centerPosDelta.latitudeDelta += COLLAPSE_LAT_DELTA_PADDING;
        centerPosDelta.longitudeDelta += COLLAPSE_LNG_DELTA_PADDING;
      }

      const bounds = {
        nw: {
          lat: centerPos.latitude + centerPosDelta.latitudeDelta,
          lng: centerPos.longitude - centerPosDelta.longitudeDelta
        },
        se: {
          lat: centerPos.latitude - centerPosDelta.latitudeDelta,
          lng: centerPos.longitude + centerPosDelta.longitudeDelta
        }
      };

      const bound = fitBounds(bounds, { width, height });

      this.setState({
        center: bound.center,
        zoom: bound.zoom + 1
      });
    }
  }
github deens-com / frontend / src / styled_scenes / EditTrip / components / TripLeftPortion / index.js View on Github external
getCenterAndZoom = markers => {
    if (!markers.length) return;
    if (markers.length === 1) {
      const center = { lat: markers[0].latitude, lng: markers[0].longitude };
      return { center, zoom: 11 };
    }
    const bounds = new window.google.maps.LatLngBounds();
    for (const marker of markers) {
      bounds.extend(new window.google.maps.LatLng(marker.latitude, marker.longitude));
    }
    const newBounds = {
      ne: { lat: bounds.getNorthEast().lat(), lng: bounds.getNorthEast().lng() },
      sw: { lat: bounds.getSouthWest().lat(), lng: bounds.getSouthWest().lng() },
    };
    const size = { width: 800, height: 450 };
    const { center, zoom } = fitBounds(newBounds, size);
    return { center, zoom };
  };
github deens-com / frontend / src / styled_scenes / Trips / index.js View on Github external
getCenterAndZoom = markers => {
    if (!markers.length) return;
    if (markers.length === 1) {
      const center = { lat: markers[0].latitude, lng: markers[0].longitude };
      return { center, zoom: 11 };
    }
    const bounds = new window.google.maps.LatLngBounds();
    for (const marker of markers) {
      bounds.extend(new window.google.maps.LatLng(marker.latitude, marker.longitude));
    }
    const newBounds = {
      ne: { lat: bounds.getNorthEast().lat(), lng: bounds.getNorthEast().lng() },
      sw: { lat: bounds.getSouthWest().lat(), lng: bounds.getSouthWest().lng() },
    };
    const size = { width: 800, height: 450 };
    const { center, zoom } = fitBounds(newBounds, size);
    return { center, zoom };
  };

google-map-react

Isomorphic component that allows rendering react components on a google map

MIT
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis