App.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. import React, { Component } from 'react';
  2. import cx from 'classnames';
  3. import './App.css';
  4. import loadJs from './lib/loadScript';
  5. import { loadMap } from './lib/api';
  6. import Map from './lib/Map';
  7. import Marker from './lib/Marker';
  8. import MassMarks from './lib/MassMarks';
  9. import LayerTraffic from './lib/LayerTraffic';
  10. import Polygon from './lib/Polygon';
  11. import Polyline from './lib/Polyline';
  12. import Circle from './lib/Circle';
  13. import InfoWindow from './lib/InfoWindow';
  14. class MarkerTest extends Component {
  15. constructor() {
  16. super();
  17. this.state = {};
  18. this._setMapRefer = this._setMapRefer.bind(this);
  19. this._setMarkerRefer = this._setMarkerRefer.bind(this);
  20. }
  21. componentDidMount() {
  22. loadMap('0325e3d6d69cd56de4980b4f28906fd8').then(AMap => {
  23. this.setState({ AMap });
  24. });
  25. }
  26. _setMapRefer (refer) {
  27. this.mapRefer = refer;
  28. window.$map = this.mapRefer;
  29. console.log('_setMapRefer:', this.mapRefer, this.markerRefer);
  30. }
  31. _setMarkerRefer (refer) {
  32. this.markerRefer = refer;
  33. window.$marker = this.markerRefer;
  34. console.log('_setMarkerRefer:', this.mapRefer, this.markerRefer);
  35. }
  36. render() {
  37. let center = [116.39, 39.9];
  38. window.$map = this.mapRefer;
  39. window.$marker = this.markerRefer;
  40. console.log('render:', this.mapRefer, this.markerRefer);
  41. let markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png';
  42. switch (this.state.markerIndex) {
  43. case 1: markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png'; break;
  44. case 2: markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png'; break;
  45. default:
  46. case 0: markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png'; break;
  47. }
  48. return (
  49. <div>
  50. <div>
  51. <div style={{margin:2}}>
  52. <span style={{marginRight:2}}>改Marker图标:</span>
  53. <span onClick={() => this.setState({ markerIndex:0 })}>
  54. Marker-0
  55. </span>
  56. <span onClick={() => this.setState({ markerIndex:1 })}>
  57. Marker-1
  58. </span>
  59. </div>
  60. <Map
  61. refer={this._setMapRefer}
  62. style={{ width: 1200, height: 800 }}
  63. options={{ center, zoom:13 }}
  64. >
  65. <LayerTraffic options={{ interval:20,opacity:0.8 }} />
  66. <Marker
  67. refer={this._setMarkerRefer}
  68. options={{
  69. icon: markerIcon,
  70. position: center
  71. }}
  72. />
  73. </Map>
  74. </div>
  75. </div>
  76. );
  77. }
  78. }
  79. class MarkerCarMoveTest extends Component {
  80. constructor() {
  81. super();
  82. this.state = {};
  83. this._setMapRefer = this._setMapRefer.bind(this);
  84. this._mapDblclick = this._mapDblclick.bind(this);
  85. this._carMoving = this._carMoving.bind(this);
  86. this._logging = this._logging.bind(this);
  87. }
  88. componentDidMount() {
  89. loadMap('0325e3d6d69cd56de4980b4f28906fd8').then(AMap => {
  90. let satellite = new AMap.TileLayer.Satellite();
  91. let roadNet = new AMap.TileLayer.RoadNet();
  92. let traffic = new AMap.TileLayer.Traffic({
  93. autoRefresh: true, //是否自动刷新,默认为false
  94. interval: 5 //刷新间隔,默认180s
  95. });
  96. let lineArr = [];
  97. let lngX = 116.397428, latY = 39.90923;
  98. lineArr.push(new AMap.LngLat(lngX, latY));
  99. for (let i = 1; i < 4; i++) {
  100. lngX = lngX + Math.random() * 0.05;
  101. if (i % 2) {
  102. latY = latY + Math.random() * 0.0001;
  103. } else {
  104. latY = latY + Math.random() * 0.06;
  105. }
  106. lineArr.push(new AMap.LngLat(lngX, latY));
  107. }
  108. let carOffset = new AMap.Pixel(-26, -13);
  109. this.setState({ AMap, lineArr, carOffset });
  110. });
  111. }
  112. _setMapRefer (refer) {
  113. this.mapRefer = refer;
  114. }
  115. _mapDblclick() {
  116. this.setState({msg:'双击了Map!'});
  117. }
  118. _carMoving(e) {
  119. this.setState({msg: '车在开', passedPath: e.passedPath});
  120. }
  121. _logging(e) {
  122. this.setState({msg: 'log:'+JSON.stringify(e.data)});
  123. }
  124. render() {
  125. console.log('mapRefer:', this.mapRefer && this.mapRefer.getLayers());
  126. let markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png';
  127. switch (this.state.markerIndex) {
  128. case 1: markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png'; break;
  129. case 2: markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png'; break;
  130. default:
  131. case 0: markerIcon = 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png'; break;
  132. }
  133. return (
  134. <div>
  135. <div>
  136. <div style={{margin:2}}>
  137. <span style={{marginRight:2}}>改Map位置:</span>
  138. <input type='button' onClick={() => this.setState({ center: [116.39, 39.9] })} value='北京' />
  139. <span onClick={() => this.setState({ center: [115.39, 38.9] })}>
  140. 北京-1
  141. </span>
  142. <span onClick={() => this.setState({ center: [114.39, 37.9] })}>
  143. 北京-2
  144. </span>
  145. </div>
  146. <div style={{margin:2}}>
  147. <span style={{marginRight:2}}>改Marker位置:</span>
  148. <span onClick={() => this.setState({ showMarker: !this.state.showMarker })}>
  149. {this.state.showMarker && '隐藏'}
  150. {!this.state.showMarker && '显示'}
  151. </span>
  152. <span onClick={() => this.setState({ position: [116.39, 39.9] })}>
  153. 北京
  154. </span>
  155. <span onClick={() => this.setState({ position: [115.39, 38.9] })}>
  156. 北京-1
  157. </span>
  158. <span onClick={() => this.setState({ position: [114.39, 37.9] })}>
  159. 北京-2
  160. </span>
  161. </div>
  162. <div style={{margin:2}}>
  163. <span style={{marginRight:2}}>改Marker图标:</span>
  164. <span onClick={() => this.setState({ markerIndex:0 })}>
  165. Marker-0
  166. </span>
  167. <span onClick={() => this.setState({ markerIndex:1 })}>
  168. Marker-1
  169. </span>
  170. </div>
  171. <div style={{margin:2}}>
  172. <input style={{margin:2, padding:2}} type='button' onClick={() => {
  173. if (this.state.carEntity) this.state.carEntity.moveAlong(this.state.lineArr, 1500);
  174. }} value='开始' />
  175. <input style={{margin:2, padding:2}} type='button' onClick={() => {
  176. if (this.state.carEntity) this.state.carEntity.pauseMove();
  177. }} value='暂停' />
  178. <input style={{margin:2, padding:2}} type='button' onClick={() => {
  179. if (this.state.carEntity) this.state.carEntity.resumeMove();
  180. }} value='继续' />
  181. <input style={{margin:2, padding:2}} type='button' onClick={() => {
  182. if (this.state.carEntity) this.state.carEntity.stopMove();
  183. }} value='停止' />
  184. </div>
  185. <div style={{margin:2}}>
  186. {'消息:'+this.state.msg}
  187. </div>
  188. <Map
  189. refer={this._setMapRefer}
  190. style={{ width: 1200, height: 800 }}
  191. options={{ center: this.state.center, zoom:13 }}
  192. events={{
  193. click:this._logging,
  194. dblclick: this._mapDblclick,
  195. }}
  196. >
  197. <LayerTraffic options={{ interval:20,opacity:0.8 }} />
  198. {this.state.showMarker &&
  199. <Marker
  200. options={{
  201. icon: markerIcon,
  202. position: this.state.position || [116.405467, 39.907761]
  203. }}
  204. events={{
  205. click:this._logging
  206. }}
  207. >
  208. </Marker>
  209. }
  210. {this.state.showMarker &&
  211. <Marker
  212. options={{
  213. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png',
  214. position: [116.385428, 39.92723],
  215. content:'<div class="marker-route marker-marker-bus-from"></div>',
  216. label: {
  217. offset: this.state.AMap && new this.state.AMap.Pixel(-30, -30),
  218. content: "我是marker的label标签"
  219. }
  220. }}
  221. events={{
  222. click:this._logging
  223. }}
  224. />
  225. }
  226. <Marker
  227. refer={(entity) => this.setState({carEntity: entity})}
  228. options={{
  229. position: [116.397428, 39.90923],
  230. icon: "https://webapi.amap.com/images/car.png",
  231. offset: this.state.carOffset,
  232. autoRotation: true
  233. }}
  234. events={{
  235. moving:this._carMoving
  236. }}
  237. />
  238. <Polyline
  239. options={{
  240. path: this.state.lineArr,
  241. strokeColor: "#00A", //线颜色
  242. // strokeOpacity: 1, //线透明度
  243. strokeWeight: 3, //线宽
  244. // strokeStyle: "solid" //线样式
  245. }}
  246. events={{
  247. click:this._logging
  248. }}
  249. />
  250. <Polyline
  251. options={{
  252. // path: lineArr,
  253. path:this.state.passedPath,
  254. strokeColor: "#F00", //线颜色
  255. // strokeOpacity: 1, //线透明度
  256. strokeWeight: 3, //线宽
  257. // strokeStyle: "solid" //线样式
  258. }}
  259. events={{
  260. click:this._logging
  261. }}
  262. />
  263. </Map>
  264. </div>
  265. </div>
  266. );
  267. }
  268. }
  269. class MassMarkTest extends Component {
  270. constructor() {
  271. super();
  272. this.state = {};
  273. this._mapDblclick = this._mapDblclick.bind(this);
  274. this._mapClick = this._mapClick.bind(this);
  275. this._changeStyle = this._changeStyle.bind(this);
  276. this._setMapRefer = this._setMapRefer.bind(this);
  277. this._setMassRefer = this._setMassRefer.bind(this);
  278. }
  279. componentDidMount() {
  280. loadMap('0325e3d6d69cd56de4980b4f28906fd8').then(AMap => {
  281. // let style = [{
  282. // url: 'https://a.amap.com/jsapi_demos/static/images/mass0.png',
  283. // anchor: new AMap.Pixel(16, 16),
  284. // size: new AMap.Size(21, 21)
  285. // },{
  286. // url: 'https://a.amap.com/jsapi_demos/static/images/mass1.png',
  287. // anchor: new AMap.Pixel(24, 24),
  288. // size: new AMap.Size(17, 17)
  289. // },{
  290. // url: 'https://a.amap.com/jsapi_demos/static/images/mass2.png',
  291. // anchor: new AMap.Pixel(23, 23),
  292. // size: new AMap.Size(5, 5)
  293. // }];
  294. this.setState({ AMap });
  295. });
  296. loadJs('https://a.amap.com/jsapi_demos/static/citys.js','js').then(ret => {
  297. console.log('ret:', ret, window.citys);
  298. // this.setState({citys:window.citys});
  299. let citys = window.citys.map ((item, index) => {
  300. return {...item, id: index};
  301. })
  302. this.setState({citys});
  303. })
  304. }
  305. _getStyle() {
  306. if (!this.styles) {
  307. if (window.AMap) {
  308. this.styles = [{
  309. url: 'https://a.amap.com/jsapi_demos/static/images/mass0.png',
  310. anchor: new window.AMap.Pixel(16, 16),
  311. size: new window.AMap.Size(21, 21)
  312. },{
  313. url: 'https://a.amap.com/jsapi_demos/static/images/mass1.png',
  314. anchor: new window.AMap.Pixel(24, 24),
  315. size: new window.AMap.Size(17, 17)
  316. },{
  317. url: 'https://a.amap.com/jsapi_demos/static/images/mass2.png',
  318. anchor: new window.AMap.Pixel(23, 23),
  319. size: new window.AMap.Size(5, 5)
  320. }];
  321. }
  322. }
  323. return this.styles;
  324. }
  325. _mapDblclick() {
  326. if (this.massRefer) {
  327. this.massRefer.show();
  328. this.massRefer.setData(this.state.citys);
  329. }
  330. this.setState({msg:'双击了Map!'});
  331. }
  332. _mapClick() {
  333. if (this.mapRefer) {
  334. let layers= this.mapRefer.getLayers();
  335. console.log('_mapClick:', layers);
  336. }
  337. }
  338. _changeStyle(item) {
  339. let style = (item.style+1) % 3;
  340. let data = this.state.citys
  341. let data2 = [...data];
  342. data2[item.id] = {...item, style};
  343. this.setState({citys:data2});
  344. }
  345. _setMapRefer (refer) {
  346. this.mapRefer = refer;
  347. }
  348. _setMassRefer (refer) {
  349. this.massRefer = refer;
  350. }
  351. render() {
  352. let massStyles = this._getStyle();
  353. return (
  354. <div>
  355. <div>
  356. <div style={{margin:2}}>
  357. <span style={{marginRight:2}}>改Map位置:</span>
  358. <input type='button' onClick={() => this.setState({ center: [116.39, 39.9] })} value='北京' />
  359. <span onClick={() => this.setState({ center: [115.39, 38.9] })}>
  360. 北京-1
  361. </span>
  362. <span onClick={() => this.setState({ center: [114.39, 37.9] })}>
  363. 北京-2
  364. </span>
  365. </div>
  366. <div style={{margin:2}}>
  367. {'消息:'+this.state.msg}
  368. </div>
  369. <Map
  370. refer={this._setMapRefer}
  371. style={{ width: 1100, height: 800 }}
  372. options={{ center: this.state.center }}
  373. events={{
  374. // click:e=>this.setState({msg: '点击了Map'}),
  375. dblclick: this._mapDblclick,
  376. click:this._mapClick
  377. }}
  378. >
  379. <MassMarks
  380. refer={this._setMassRefer}
  381. options={{
  382. data: this.state.citys,
  383. opacity:0.8,
  384. zIndex: 111,
  385. cursor:'pointer',
  386. style: massStyles
  387. }}
  388. events={{
  389. click:e=> {
  390. console.log('e:', e);
  391. this._changeStyle(e.data);
  392. this.setState({msg: '点击了MassMarks:'+JSON.stringify(e.data)})
  393. }
  394. }}
  395. >
  396. </MassMarks>
  397. </Map>
  398. </div>
  399. </div>
  400. );
  401. }
  402. }
  403. class PolygonTest extends Component {
  404. constructor() {
  405. super();
  406. this.state = {};
  407. this._mapDblclick = this._mapDblclick.bind(this);
  408. this._changeStyle = this._changeStyle.bind(this);
  409. }
  410. componentDidMount() {
  411. loadMap('0325e3d6d69cd56de4980b4f28906fd8').then(AMap => {
  412. let roadNet = new AMap.TileLayer.RoadNet();
  413. let traffic = new AMap.TileLayer.Traffic({
  414. autoRefresh: true, //是否自动刷新,默认为false
  415. interval: 15 //刷新间隔,默认180s
  416. });
  417. this.setState({ AMap, layers: [roadNet, traffic], poly: 0 });
  418. });
  419. }
  420. _mapDblclick() {
  421. this.setState({msg:'双击了Map!'});
  422. }
  423. _changeStyle() {
  424. this.setState({poly:1})
  425. }
  426. render() {
  427. let poly0 = [//多边形覆盖物节点坐标数组
  428. [116.403322, 39.920255],
  429. [116.410703, 39.897555],
  430. [116.402292, 39.892353],
  431. [116.389846, 39.891365]
  432. ];
  433. let poly1 = [//多边形覆盖物节点坐标数组
  434. [116.404322, 39.920355],
  435. [116.411703, 39.897355],
  436. [116.402392, 39.892453],
  437. [116.381946, 39.881465]
  438. ];
  439. let poly = (this.state.poly == 0) ? poly0: poly1;
  440. return (
  441. <div>
  442. <div>
  443. <div style={{margin:2}}>
  444. <span style={{marginRight:2}}>改Map位置:</span>
  445. <input type='button' onClick={() => this.setState({ poly:0 })} value='poly0' />
  446. <input type='button' onClick={() => this.setState({ poly:1 })} value='poly1' />
  447. </div>
  448. <div style={{margin:2}}>
  449. {'消息:'+this.state.msg}
  450. </div>
  451. <Map
  452. style={{ width: 1100, height: 800 }}
  453. options={{ center: this.state.center, layers: this.state.layers }}
  454. events={{
  455. // click:e=>this.setState({msg: '点击了Map'}),
  456. dblclick: this._mapDblclick,
  457. }}
  458. >
  459. <Polygon
  460. options={{
  461. path: poly,
  462. strokeColor: "#FF33FF", //线颜色
  463. strokeOpacity: 0.2, //线透明度
  464. strokeWeight: 3, //线宽
  465. fillColor: "#1791fc", //填充色
  466. fillOpacity: 0.35,//填充透明度
  467. extData: {poly:this.state.poly}
  468. }}
  469. events={{
  470. click:e=> {
  471. console.log('e:', e);
  472. this._changeStyle(e.data);
  473. this.setState({msg: '点击了Poly:'+JSON.stringify(e.data)})
  474. }
  475. }}
  476. />
  477. </Map>
  478. </div>
  479. </div>
  480. );
  481. }
  482. }
  483. class CircleTest extends Component {
  484. constructor() {
  485. super();
  486. this.state = {};
  487. }
  488. componentDidMount() {
  489. loadMap('0325e3d6d69cd56de4980b4f28906fd8').then(AMap => {
  490. let roadNet = new AMap.TileLayer.RoadNet();
  491. let traffic = new AMap.TileLayer.Traffic({
  492. autoRefresh: true, //是否自动刷新,默认为false
  493. interval: 15 //刷新间隔,默认180s
  494. });
  495. this.setState({ AMap, layers: [roadNet, traffic], center: [116.403322, 39.920255], radius: 1000 });
  496. });
  497. }
  498. _mapDblclick = (e) => {
  499. let center = [e.lnglat.getLng(), e.lnglat.getLat()];
  500. this.setState({msg:'双击了Map!', center});
  501. }
  502. _mapClick = (e) => {
  503. let center = [e.lnglat.getLng(), e.lnglat.getLat()];
  504. this.setState({msg:'双击了Map!', center});
  505. }
  506. _changeRadius200 = () => {
  507. this.setState({radius:500})
  508. }
  509. _changeRadius1000 = () => {
  510. this.setState({radius:2000})
  511. }
  512. render() {
  513. let { center, radius} = this.state;
  514. return (
  515. <div>
  516. <div>
  517. <div style={{margin:2}}>
  518. <span style={{marginRight:2}}>改变半径radius:</span>
  519. <input type='button' onClick={this._changeRadius200} value='radius200' />
  520. <input type='button' onClick={this._changeRadius1000} value='radius1000' />
  521. </div>
  522. <div style={{margin:2}}>
  523. {'消息:'+this.state.msg}
  524. </div>
  525. <Map
  526. style={{ width: 1100, height: 800 }}
  527. options={{ center: this.state.center, layers: this.state.layers }}
  528. events={{
  529. click: this._mapClick,
  530. dblclick: this._mapDblclick,
  531. }}
  532. >
  533. <Circle
  534. options={{
  535. center,
  536. radius,
  537. strokeColor: "#FF33FF", //线颜色
  538. strokeOpacity: 0.2, //线透明度
  539. strokeWeight: 3, //线宽
  540. fillColor: "#1791fc", //填充色
  541. fillOpacity: 0.35,//填充透明度
  542. }}
  543. events={{
  544. click:this._mapClick
  545. }}
  546. />
  547. </Map>
  548. </div>
  549. </div>
  550. );
  551. }
  552. }
  553. class InfoWindowTest extends Component {
  554. constructor() {
  555. super();
  556. this.state = {};
  557. this._closeInfoWindow = this._closeInfoWindow.bind(this);
  558. }
  559. componentDidMount() {
  560. loadMap('0325e3d6d69cd56de4980b4f28906fd8').then(AMap => {
  561. let roadNet = new AMap.TileLayer.RoadNet();
  562. let center1 = new AMap.LngLat(116.403322, 39.920255);
  563. let center2 = new AMap.LngLat(116.405522, 39.921265);
  564. let offset = new AMap.Pixel(Math.random() * 10, Math.random() * 10)
  565. this.setState({ AMap, layers: [roadNet], center: center1, center1, center2, offset });
  566. });
  567. }
  568. _closeInfoWindow(evt) {
  569. console.log ('close infowindow!');
  570. this.setState({isOpen:false})
  571. }
  572. render() {
  573. const html = `<div><h4>Greetings</h4><p>This is content of this info window</p><p>Click 'Change Value' Button:</p></div>`;
  574. const size = {
  575. width: 250 + Math.random() * 20,
  576. height: 140 + Math.random() * 20,
  577. }
  578. return (
  579. <div>
  580. <div>
  581. <div style={{margin:2}}>
  582. <input type='button' onClick={() => this.setState({ isOpen:true })} value='显示' />
  583. <input type='button' onClick={() => this.setState({ isOpen:false })} value='隐藏' />
  584. <input type='button' onClick={() => this.setState({ center: this.state.center1 })} value='center1' />
  585. <input type='button' onClick={() => this.setState({ center: this.state.center2 })} value='center2' />
  586. </div>
  587. <Map
  588. style={{ width: 1100, height: 800 }}
  589. options={{ center: this.state.center, layers: this.state.layers }}
  590. >
  591. {this.state.isOpen && (
  592. <InfoWindow
  593. options={{
  594. position: this.state.center,
  595. isCustom:false,
  596. content:html,
  597. size,
  598. offset: this.state.offset
  599. }}
  600. events={{
  601. close: this._closeInfoWindow
  602. }}
  603. />
  604. )}
  605. </Map>
  606. </div>
  607. </div>
  608. );
  609. }
  610. }
  611. class App extends Component {
  612. constructor() {
  613. super();
  614. this.state = {};
  615. }
  616. render() {
  617. return (
  618. <div>
  619. <div>
  620. <span style={{padding:5, margin: 5, backgroundColor:(this.state.test === 'marker')?'#ff0':'#fff'}} onClick={()=>this.setState({test: 'marker'})}> MarkerTest </span>
  621. <span style={{padding:5, margin: 5, backgroundColor:(this.state.test === 'markercarmove')?'#ff0':'#fff'}} onClick={()=>this.setState({test: 'markercarmove'})}> 移动的汽车(MarkerCarMoveTest) </span>
  622. <span style={{padding:5, margin: 5, backgroundColor:(this.state.test === 'massmarks')?'#ff0':'#fff'}} onClick={()=>this.setState({test: 'massmarks'})}> MassMarksTest </span>
  623. <span style={{padding:5, margin: 5, backgroundColor:(this.state.test === 'polygon')?'#ff0':'#fff'}} onClick={()=>this.setState({test: 'polygon'})}> PolygonTest </span>
  624. <span style={{padding:5, margin: 5, backgroundColor:(this.state.test === 'circle')?'#ff0':'#fff'}} onClick={()=>this.setState({test: 'circle'})}> CircleTest </span>
  625. <span style={{padding:5, margin: 5, backgroundColor:(this.state.test === 'infowindow')?'#ff0':'#fff'}} onClick={()=>this.setState({test: 'infowindow'})}> InfoWindowTest </span>
  626. </div>
  627. <div>
  628. {this.state.test === 'marker' &&
  629. <MarkerTest />
  630. }
  631. {this.state.test === 'markercarmove' &&
  632. <MarkerCarMoveTest />
  633. }
  634. {this.state.test === 'massmarks' &&
  635. <MassMarkTest />
  636. }
  637. {this.state.test === 'polygon' &&
  638. <PolygonTest />
  639. }
  640. {this.state.test === 'circle' &&
  641. <CircleTest />
  642. }
  643. {this.state.test === 'infowindow' &&
  644. <InfoWindowTest />
  645. }
  646. </div>
  647. </div>
  648. );
  649. }
  650. }
  651. export default App;