-
Notifications
You must be signed in to change notification settings - Fork 935
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DrawingManager): Support for Drawing API
- Loading branch information
Showing
10 changed files
with
153 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
examples/gh-pages/scripts/components/drawing/DrawingTools.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from "react/addons"; | ||
import {GoogleMaps, DrawingManager} from "react-google-maps"; | ||
|
||
/* | ||
* https://developers.google.com/maps/documentation/javascript/examples/drawing-tools | ||
* | ||
* Note: requires the Google Maps drawing API library in your script src | ||
*/ | ||
class DrawingTools extends React.Component { | ||
|
||
constructor (...args) { | ||
super(...args); | ||
this.state = { | ||
zoom: 8, | ||
center: new google.maps.LatLng(-34.397, 150.644), | ||
}; | ||
} | ||
|
||
render () { | ||
const {props, state} = this, | ||
{googleMapsApi, ...otherProps} = props; | ||
|
||
return ( | ||
<GoogleMaps containerProps={{ | ||
...otherProps, | ||
style: { | ||
height: "100%", | ||
}, | ||
}} | ||
ref="map" | ||
googleMapsApi={google.maps} | ||
zoom={state.zoom} | ||
center={state.center}> | ||
|
||
<DrawingManager | ||
drawingMode={google.maps.drawing.OverlayType.CIRCLE} | ||
drawingControl={true} | ||
drawingControlOptions={{ | ||
position: google.maps.ControlPosition.TOP_CENTER, | ||
drawingModes: [ | ||
google.maps.drawing.OverlayType.CIRCLE, | ||
google.maps.drawing.OverlayType.POLYGON, | ||
google.maps.drawing.OverlayType.POLYLINE, | ||
google.maps.drawing.OverlayType.RECTANGLE | ||
] | ||
}} | ||
circleOptions={{ | ||
fillColor: '#ffff00', | ||
fillOpacity: 1, | ||
strokeWeight: 5, | ||
clickable: false, | ||
editable: true, | ||
zIndex: 1 | ||
}} | ||
/> | ||
|
||
</GoogleMaps> | ||
); | ||
} | ||
|
||
} | ||
|
||
export default DrawingTools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } | ||
|
||
var _internalsSimpleChildComponent = require("./internals/SimpleChildComponent"); | ||
|
||
var _internalsSimpleChildComponent2 = _interopRequireDefault(_internalsSimpleChildComponent); | ||
|
||
var _internalsCreateRegisterEvents = require("./internals/createRegisterEvents"); | ||
|
||
var _internalsCreateRegisterEvents2 = _interopRequireDefault(_internalsCreateRegisterEvents); | ||
|
||
var DrawingManager = (function (_SimpleChildComponent) { | ||
function DrawingManager() { | ||
_classCallCheck(this, DrawingManager); | ||
|
||
if (_SimpleChildComponent != null) { | ||
_SimpleChildComponent.apply(this, arguments); | ||
} | ||
} | ||
|
||
_inherits(DrawingManager, _SimpleChildComponent); | ||
|
||
return DrawingManager; | ||
})(_internalsSimpleChildComponent2["default"]); | ||
|
||
DrawingManager._GoogleMapsClassName = "drawing.DrawingManager"; | ||
|
||
DrawingManager._registerEvents = _internalsCreateRegisterEvents2["default"]("drawingmode_changed overlaycomplete markercomplete circlecomplete polygoncomplete polylinecomplete rectanglecomplete"); | ||
|
||
exports["default"] = DrawingManager; | ||
module.exports = exports["default"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import SimpleChildComponent from "./internals/SimpleChildComponent"; | ||
import createRegisterEvents from "./internals/createRegisterEvents"; | ||
|
||
class DrawingManager extends SimpleChildComponent { | ||
} | ||
|
||
DrawingManager._GoogleMapsClassName = "drawing.DrawingManager"; | ||
|
||
DrawingManager._registerEvents = createRegisterEvents( | ||
"drawingmode_changed overlaycomplete markercomplete circlecomplete polygoncomplete polylinecomplete rectanglecomplete" | ||
); | ||
|
||
export default DrawingManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters