ReactiveGoogleMap Image

ReactiveGoogleMap creates a data-driven map UI component using Google Maps. It is the key component for building map based experiences.

Example uses:

  • showing a map of user check-ins by city and topics for powering discovery based experiences.
  • displaying restaurants filtered by a nearby distance query on a map.



<reactive-google-map /> uses Google Maps JS library to render the google map and access the necessary geo-location services. To configure the google maps you have to install the ReactiveGoogleMap plugin with google maps key. For example,

import Vue from 'vue';
import App from './App.vue';
import {
} from '@appbaseio/reactivesearch-vue';

// Installing the ReactiveGoogleMap plugin
Vue.use(ReactiveGoogleMap, {
    key: 'PUT_YOUR_MAP_KEY',
Vue.config.productionTip = false;

new Vue({
    render: h => h(App),

Nuxt.js config

If you're using Nuxt.js then you have to add the following to the build section of your nuxt.config.js file:

transpile: [/^gmap-vue($|\/)/, /^@appbaseio\/reactivesearch-vue($|\/)/],

You can also check this example with Nuxt.js.

Basic Usage


Usage With All Props

    :defaultCenter="{ lat: 37.74, lng: -122.45 }"
        and: 'CitySensor',


  • componentId String unique identifier of the component, can be referenced in other components' react prop.

  • dataField String DB data field to be connected to the component's UI view, usually of a geopoint (i.e. location) data type and used for rendering the markers on the map.

  • size Number [optional] number of results to show in the map view, can be a number in the range [1, 1000]. Defaults to 10.

  • calculateMarkers Function [optional] The ReactiveGoogleMap component uses the ElasticSearch hits to render the markers, if you wish to override the default markers then calculateMarkers prop is the way. The calculateMarkers function accepts an object with following properties:

    • data, parsed hits data
    • rawData, Elasticsearch raw response

    The function must return an array of markers where each marker must have the following properties:

    • _id, unique identifier for each marker
    • [dataField], location object with lat and lng values.

    Note: The dataField key should be similar to the dataField prop defined for the ReactiveGoogleMap component. For example, if your dataField name is location then the marker object would look like below:

        "_id": "xyz",
        "location": {
            lat: 37.7749,
            lng: 122.4194,

    You can check the following example that uses the Elasticsearch aggregations to render the markers.

  • clusterProps Object [optional] can be used to bind the properties to the Google Maps Cluster object. It supports the following properties:

    • maxZoom Number
    • batchSizeIE Number
    • calculator Function
    • enableRetinaIcons Boolean
    • gridSize Boolean
    • averageCenter Boolean
    • ignoreHidden Boolean
    • imageExtension Boolean
    • imagePath String
    • imageSizes Array
    • minimumClusterSize Number
    • clusterClass String
    • styles Array
    • zoomOnClick Boolean
  • defaultZoom Number [optional] preset map's zoom level, accepts integer values between [0, 20]. 0 is the minimum zoom level, where you can see the entire globe. 20 is the maximum zoom level. Defaults to 13.

  • defaultCenter Object [optional] preset map's center position by specifying an object with valid lat and lng values. This prop, when set, will cause the component to run a geo-distance query with a distance of 10mi (Refer: defaultRadius and unit prop to configure the distance).

  • defaultQuery Function [optional] applies a default query to the map component. This query will be run when no other components are being watched (via React prop), as well as in conjunction with the query generated from the React prop. The function should return a query. Read more about it here. The following example uses the defaultQuery with calculateMarkers to display the markers using Elasticsearch aggregations instead of hits. The following example changes the defaultQuery whenever the zoom value changes.

  • center Object [optional] set map's center position by specifying an object with valid lat and lng values. This prop, when set, will cause the component to run a geo-distance query with a distance of 10mi (Refer: defaultRadius and unit prop to configure the distance).

  • defaultRadius Number [optional] used as distance value for the geo-distance query when defaultCenter or center is set. It accepts all positive integers.

  • unit String [optional] unit for distance measurement, uses mi (for miles) by default. Distance units can be specified from the following: screenshot

  • showMarkers Boolean [optional] whether to show the markers on the map, defaults to true. Sometimes, it doesn't make sense to display markers (when building a heatmap or weather map or a directions navigation map)

  • defaultPin String [optional] URL of the default marker pin image to be shown. It comes with a default image. Should only be set if you wish to use a custom marker.

  • showMarkerClusters Boolean [optional] whether to aggregate and form a cluster of nearby markers. Defaults to true.


  1. It requires showMarkers prop enabled.
  2. You have to define the [m1-m5] cluster images at public/images folder. Please check this example.
  • showSearchAsMove Boolean [optional] whether to show the Search As I Move checkbox in the UI. Defaults to true.

  • searchAsMove Boolean [optional] whether to set the Search As I Move checkbox. Defaults to false.

  • autoClosePopover Boolean [optional] automatically closes the existing open popovers when a new marker is clicked. Defaults to false.

  • react Object [optional] specify dependent components to reactively update ReactiveGoogleMap's options. Read more about it here.

    • key String one of and, or, not defines the combining clause.

      • and clause implies that the results will be filtered by matches from all of the associated component states.
      • or clause implies that the results will be filtered by matches from at least one of the associated component states.
      • not clause implies that the results will be filtered by an inverse match of the associated component states.
    • value String or Array or Object

      • String is used for specifying a single component by its componentId.
      • Array is used for specifying multiple components by their componentId.
      • Object is used for nesting other key clauses.
  • autoCenter Boolean [optional] whether to auto center the map based on the geometric center of all the location markers. Defaults to false.

  • className String [optional] CSS class to be injected on the component container.

  • style Object [optional] CSS style object to be applied to the ReactiveGoogleMap component.

  • pagination Boolean [optional] When set to true, a pagination based list view with page numbers will appear.

  • renderItem Function|slot-scope [optional] useful to customize the markers. It can be defined as a Function or slot. The following example would render the marker with a label.

        :renderItem="result => ({
            label: result.title,

    The following example would render the marker with an icon.

       :renderItem="result => ({
           icon: '',

    The following example uses the slot to customize the marker.

        <div slot="renderItem" slot-scope="{ magnitude }">
  • renderPopover slot-scope [optional] It is useful to render the popover content when a marker is clicked.

    The following example displays the title and description in popover.

        <div slot="renderPopover" slot-scope="{ title, description }">
           <div>{{ title }}</div>
           <p>{{ description }}</p>
  • renderClusterPopover slot-scope [optional] It is useful to render the popover content when a cluster is clicked.

    The following example displays the markers information for a particular cluster.

        <div slot="renderClusterPopover" slot-scope="{ markers, cluster }">
           <pre>{{ JSON.stringify(markers, null, 2) }}</pre>

    alt cluster

  • render slot-scope [optional] The render slot can be used to render the results in a list based UI.
    It accepts an object with these properties:

    • loading: boolean indicates that the query is still in progress
    • error: object An object containing the error info
    • data: array An array of results obtained from combining stream and promoted results along with the hits .
    • promotedData: array An array of promoted results obtained from the applied query. Read More


      data, streamData and promotedData results has a property called _click_id which can be used with triggerClickAnalytics to register the click analytics info.

    • customData object Custom data set in the query rule when is used as backend. Read More
    • rawData object An object of raw response as-is from elasticsearch query.
    • resultStats: object An object with the following properties which can be helpful to render custom stats:

      • numberOfResults: number Total number of results found
      • numberOfPages: number Total number of pages found based on current page size
      • currentPage: number Current page number for which data is being rendered
      • time: number Time taken to find total results (in ms)
      • displayedResults: number Number of results displayed in current view
      • hidden: number Total number of hidden results found
      • promoted: number Total number of promoted results found
    • loadMore: function A callback function to be called to load the next page of results into the view.
    • triggerClickAnalytics: function A function which can be called to register a click analytics. Read More
    • setPage: function A function which will allow to dispatch a page change event when using custom pagination. It accepts pageNumber as its parameter.
        <div slot="render" slot-scope="{ loading, error, data }">
            <div v-if="loading">Fetching Results.</div>
            <div v-if="Boolean(error)">Something went wrong! Error details {{JSON.stringify(error)}}</div>
            <ul v-bind:key="result._id" v-for="result in data">
                    <!-- Render UI -->
  • renderError String|Function|slot-scope [optional] can be used to render an error message in case of any error.

    <template slot="renderError" slot-scope="error">
        <div>Something went wrong!<br />Error details<br />{{ error }}</div>



ReactiveGoogleMap component supports innerClass prop with the following keys:

  • checkboxContainer
  • checkbox
  • label


  • queryChange is an event which accepts component's prevQuery and nextQuery as parameters. It is called everytime the component's query changes. This event is handy in cases where you want to generate a side-effect whenever the component's query would change.

  • pageClick accepts a function which is invoked with the updated page value when a pagination button is clicked. For example if 'Next' is clicked with the current page number as '1', you would receive the value '2' as the function parameter.

  • data Function [optional] gets triggered after data changes, which returns an object with these properties: data,promotedData, rawData, customData & resultStats.

  • error gets triggered in case of an error and provides the error object, which can be used for debugging or giving feedback to the user if needed.

  • zoom-changed called whenever map zoom gets changed

  • drag-end gets triggered when map drag ends

  • idle gets called when map is in idle position

  • open-marker-popover gets called when marker popover gets opened or marker is clicked

  • close-marker-popover gets called when marker popover is closed

  • open-cluster-popover gets called when cluster popover gets opened or cluster is clicked

  • close-cluster-popover gets called when cluster popover is closed


ReactiveGoogleMap component can be extended to

  1. customize the look and feel with className and style props,
  2. render the results in a customized view using render slot.
  3. customize the markers using renderItem slot.
  4. customize popover content using renderPopover slot.
  5. get the google map reference using refs. The getMapRef method of ReactiveGoogleMap component would return the map ref.


ReactiveGoogleMap with all the default props