const { __ } = wp.i18n;
const {
registerBlockType
} = wp.blocks;
const {
InspectorControls,
BlockControls,
AlignmentToolbar
} = wp.editor;
const {
PanelBody,
PanelRow,
TextControl
} = wp.components;
const {
Fragment
} = wp.element;
registerBlockType('advanced-blocks/map', {
title: "Map",
icon: 'location-alt',
category: 'advanced-blocks',
supports: {
align: true
},
attributes: {
mapLocation: {
type: 'string',
default: 'guggenheim museum new york'
},
mapHeight: {
type: 'string',
default: '400px'
},
mapWidth: {
type: 'string',
default: '400px'
},
},
// props are passed to edit by default
// props contains things like setAttributes and attributes
edit(props) {
// we are peeling off the things we need
const {
setAttributes,
attributes,
className, // The class name as a string!
focus // this is "true" when the user clicks on the block
} = props;
const { mapLocation, mapHeight,mapWidth } = props.attributes;
function onMapLocationChange(changes) {
setAttributes({
mapLocation: changes
});
}
function onMapHeightChange(changes) {
setAttributes({
mapHeight: changes
})
}
function onMapWidthChange(changes) {
setAttributes({
mapWidth: changes
})
}
return ([
{ __('Enter your location or address and map will be fetched from Google Maps.') }