Skip to content

Commit

Permalink
fix(blocks-google-maps): Fix load script libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gervwyk committed Jun 23, 2022
1 parent 3edbd9a commit c9376f0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
Expand Up @@ -30,13 +30,7 @@ function updateHeatmap(data) {
}

const GoogleMapsHeatmap = ({ blockId, content, methods, properties }) => (
<Map
blockId={blockId}
content={content}
methods={methods}
properties={properties}
libraries={['visualization']}
>
<Map blockId={blockId} content={content} methods={methods} properties={properties}>
{(map, bounds) =>
map &&
bounds &&
Expand All @@ -49,7 +43,7 @@ const GoogleMapsHeatmap = ({ blockId, content, methods, properties }) => (
(properties.heatmap?.data || []).map((item) => updateHeatmap(item))
}
onLoad={() => {
if (properties.autoBounds !== false && bounds) {
if (properties.autoBounds !== false && bounds && map) {
(properties.heatmap?.data || []).forEach((item) => {
bounds.extend(item);
});
Expand Down
Expand Up @@ -23,7 +23,7 @@ const LIBRARIES = [];
class GoogleMapsScript extends React.Component {
constructor(props) {
super(props);
this.libraries = [...new Set(props.libraries || [])];
this.libraries = [...new Set(props.properties?.libraries || [])];
}
render() {
const { blockId, properties, content } = this.props;
Expand Down
@@ -0,0 +1,27 @@
{
"type": "object",
"properties": {
"type": "object",
"additionalProperties": false,
"properties": {
"apiKey": {
"type": "string",
"description": "Your Goolge Maps API key."
}
}
},
"events": {
"type": "object",
"additionalProperties": false,
"properties": {
"onClick": {
"type": "array",
"description": "Trigger actions when the map is clicked."
},
"onMarkerClick": {
"type": "array",
"description": "Trigger actions when marker is clicked."
}
}
}
}
Expand Up @@ -97,7 +97,7 @@ const Map = ({ blockId, children, content, methods, properties }) => {
});
}}
>
{content.content()}
{content.infoWindow()}
</InfoWindow>
)}
{children(map, bounds)}
Expand Down

0 comments on commit c9376f0

Please sign in to comment.