ReactiveGoogleMap
creates a data-driven map UI component using Google Maps. It is the key component for building map based experiences.
Example uses:
<ReactiveGoogleMap componentId="MapUI" dataField="location" title="Venue Location Map" />
Usage With All Props
<ReactiveGoogleMap
componentId="MapUI"
compoundClause="filter"
dataField="location"
title="Venue Location Map"
size={10}
defaultZoom={13}
defaultCenter={{ lat: 37.74, lng: -122.45 }}
showMapStyles={true}
defaultMapStyle="Standard"
showMarkerClusters={true}
showSearchAsMove={true}
searchAsMove={true}
onPopoverClick={this.onPopoverClick}
react={{
and: 'CitySensor',
}}
renderItem={this.renderItem}
autoCenter={true}
/>
Props componentId
unique identifier of the component, can be referenced in other components' react
prop.
Configure whether the DSL query is generated with the compound clause of must
or filter
. If nothing is passed the default is to use must
. Setting the compound clause to filter allows search engine to cache and allows for higher throughput in cases where scoring isn’t relevant (e.g. term, geo or range type of queries that act as filters on the data)
This property only has an effect when the search engine is either elasticsearch or opensearch.
dataFieldNote:
compoundClause
is supported with v8.16.0 (server) as well as with serverless search.
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.
sizenumber of results to show in the map view, can be a number in the range [1, 1000]. Defaults to 10.
defaultZoompreset 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.
defaultCenterpreset 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).
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).
used as distance value for the geo-distance query when defaultCenter
or center
is set. It accepts all positive integers.
unit for distance measurement, uses mi
(for miles) by default. Distance units can be specified from the following:
Boolean
Yes
whether to show map styles dropdown picker in the map UI. Defaults to true
.
preset a map style for the map UI. Available options include "Standard", "Blue Essence", "Blue Water", "Flat Map", "Light Monochrome", "Midnight Commander", "Unsaturated Browns".
showMarkers Type OptionalBoolean
Yes
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)
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 Type OptionalBoolean
Yes
whether to aggregate and form a cluster of nearby markers. Defaults to true
.
showSearchAsMove Type OptionalNote
It requires
showMarkers
prop enabled.
Boolean
Yes
whether to show the Search As I Move checkbox in the UI. Defaults to true
.
Boolean
Yes
whether to set the Search As I Move checkbox. Defaults to false
.
function
Yes
a function that takes one argument for getting a marker's data and returns an HTML markup to be displayed in the popover box.
autoClosePopover Type OptionalBoolean
Yes
automatically closes the exisiting open popovers when onPopoverClick
gets fired. Defaults to false
.
specify dependent components to reactively update GeoDistanceDropdown'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.
Boolean
Yes
whether to auto center the map based on the geometric center of all the location markers. Defaults to false
.
CSS class to be injected on the component container.
styleCSS style object to be applied to the ReactiveGoogleMap
component.
function
Yes
event fired when one or more markers are indexed, updated or removed from the map. It takes an object with the following formats (label
, icon
, custom
):
renderItem={result => ({
label: result.title,
})}
renderItem={result => ({
icon: 'https://i.imgur.com/NHR2tYL.png',
})}
renderItem={result => ({
custom: (<div>{result.mag}</div>),
})}
render Type Optional function
Yes
an alternative callback function to renderItem
, where user can define how to render the view based on all the data changes.
It accepts an object with these properties:
loading
: boolean
indicates that the query is still in progresserror
: object
An object containing the error infodata
: array
An array of results obtained from combining promoted
results along with the hits
.aggregationData
array
An array of aggregations buckets. Each bucket would have a top_hits
property if you're using Elasticsearch top hits aggregations in defaultQuery
prop.promotedData
: array
An array of promoted results obtained from the applied query. Read MoreNote:
data
andpromotedData
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 appbase.io is used as backend. Read MorerawData
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 foundnumberOfPages
: number
Total number of pages found based on current page sizecurrentPage
: number
Current page number for which data is being renderedtime
: number
Time taken to find total results (in ms)displayedResults
: number
Number of results displayed in current viewhidden
: number
Total number of hidden results foundpromoted
: number
Total number of promoted results foundloadMore
: function
A callback function to be called to load the next page of results into the view. The callback function is only applicable in the case of infinite loading view (i.e. infiniteScroll
prop set to true
).triggerClickAnalytics
: function
A function which can be called to register a click analytics. Read Morerender={(props) => {
const
{
data,
loading,
error,
promotedData,
customData,
rawData,
resultStats: {
numberOfResults
numberOfPages
currentPage
displayedResults
time
hidden
promoted
},
loadMore
triggerClickAnalytics
setPage,
renderMap
renderPagination
} = props;
return(
<>
{data.map(hit => <pre onClick={() => triggerClickAnalytics(hit._click_id)}>{JSON.stringify(hit)}</pre>)}
{renderMap()}
</pre>
)
}
Or you can also use render function as children
<ReactiveGoogleMap
>
{
({
loading,
error,
data,
promotedData,
rawData,
resultStats,
handleLoadMore,
triggerClickAnalytics
}) => (
)
}
</ReactiveGoogleMap>
renderError Type Optional String or JSX or Function
Yes
can be used to render an error message in case of any error.
renderError={(error) => (
<div>
Something went wrong!<br/>Error details<br/>{error}
</div>
)
}
onError Type Optional Function
Yes
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.
Function
Yes
gets triggered after data changes, which returns an object with these properties: data
, promotedData
, customData
, rawData
& resultStats
.
ReactiveGoogleMap
component supports innerClass
prop with the following keys:
title
input
list
checkboxContainer
checkbox
label
select
icon
count
button
pagination
active
ReactiveGoogleMap with all the default props
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4