hier verfügbar<\/A>. Ich werde nicht die gesamte Anwendung im Detail durchgehen, möchte aber die Widgets hervorheben.<\/P><\/P>
Zuerst gibt es ein Widget namens Locator, das einfach die Kartenkoordinaten des Cursors anzeigt.<\/P>
\/** @jsx React.DOM *\/
define([\n 'react',\n 'dojo/topic',\n 'helpers/NumFormatter'\n], function(\n React,\n topic,\n format\n) {\n var fixed = format(3);\n var LocatorWidget = React.createClass({\n getInitialState: function() {\n return {\n x: 0,\n y: 0\n };\n },\n componentDidMount: function() {\n this.handler = this.props.map.on('mouse-move', function(e) {\n this.update(e.mapPoint);\n }.bind(this));\n },\n componentWillUnMount: function() {\n this.handler.remove();\n },\n update: function(data) {\n this.setState(data);\n topic.publish('map-mouse-move', data);\n },\n render: function() {\n return (\n <div className='well'>\n <label>x: {fixed(this.state.x)}</label>\n :& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:& nbsp:
\n < P > Diese Komponente ist ziemlich einfach. Sie zeigt nur Koordinaten an und verwendet < A href = "http://dojotoolkit.org/reference-guide/1.10/dojo/topic.html " rel = "nofollow noopener noreferrer" target = "_blank" > dojo/topic < /A > , um diese Koordinaten an die Anwendung zu veröffentlichen. < A _jive_internal = "true" href = "https://community.esri.com/people/odoe/blog/2014/12/02/stay-on-topic" target = "_blank" > Ich habe schon einmal über dojo/topic gesprochen < /A > . Die nächste Komponente ist etwas interessanter. Sie hat eine Schaltfläche, die ein < A href = "https://developers.arcgis.com/javascript/jsapi/draw-amd.html" rel = "nofollow noopener noreferrer" target = "_blank" > Zeichentool < /A > aktiviert und ein Label, das die gezeichnete Entfernung anzeigt.< /P >< P >< /P >< PRE class = "lia-code-sample line-numbers language-none" > \/** @jsx React.DOM * \/
define([
'react',
'esri/toolbars/draw',
'esri/geometry/geometryEngine',
'dojo/topic',
'dojo/on',
'helpers/NumFormatter'
], function(
React,
Draw, geomEngine,
topic, on,
format
) {
var fixed = format(3);
var DrawToolWidget = React.createClass({
getInitialState: function() {
return {
startPoint: null,
btnText: 'Linie zeichnen',
istance: 0,
x: 0,y: 0
};},componentDidMount:function(){this.draw=new Draw(this.props.map);this.handler=this.draw.on('draw-end', this.onDrawEnd);this.subscriber=topic.subscribe('map-mouse-move', this.mapCoordsUpdate);},componentWillUnMount:function(){this.handler.remove();this.subscriber.remove();},onDrawEnd:function(e){this.draw.deactivate();this.setState({startPoint:null,btnText:'Linie zeichnen'});},mapCoordsUpdate:function(data){this.setState(data);// bin mir nicht sicher ob ich diese Bedingungsprüfung mag
if (this.state.startPoint) {this.updateDistance(data);}},updateDistance:function(endPoint){var distance=geomEngine.distance(this.state.startPoint,endPoint);this.setState({distance:distance});},drawLine:unction(){this.setState({btnText:'Zeichne...'});this.draw.activate(Draw.POLYLINE);on.once(this.props.map,'click',function(e){this.setState({startPoint:e.mapPoint});// sehr hacky aber Draw.LINE Interaktion ist seltsam zu benutzen
on.once(this.props.map,'click',function(){this.onDrawEnd();}.bind(this));}.bind(this))},unction(){
return (
{this.state.btnText}