1- /** @jsx React.DOM */
21"use strict" ;
32require ( "../styles/index.scss" ) ;
43var React = require ( "react/addons" ) ;
@@ -14,20 +13,20 @@ function geometryToComponentWithLatLng (geometry) {
1413 switch ( type ) {
1514 case "Polygon" :
1615 return {
17- Component : Polygon ,
16+ ElementClass : Polygon ,
1817 paths : coordinates . map ( geometryToComponentWithLatLng , { type : "LineString" } ) [ 0 ]
1918 } ;
2019 case "LineString" :
2120 coordinates = coordinates . map ( geometryToComponentWithLatLng , { type : "Point" } ) ;
2221 return typeFromThis ? coordinates : {
23- Component : Polyline ,
22+ ElementClass : Polyline ,
2423 path : coordinates
2524 } ;
2625 case "Point" :
2726 coordinates = new google . maps . LatLng ( coordinates [ 1 ] , coordinates [ 0 ] ) ;
2827 return typeFromThis ? coordinates : {
29- Component : Marker ,
30- ChildComponent : InfoWindow ,
28+ ElementClass : Marker ,
29+ ChildElementClass : InfoWindow ,
3130 position : coordinates
3231 } ;
3332 default :
@@ -149,53 +148,37 @@ var Body = React.createClass({
149148
150149 _render ( props , state ) {
151150 var { geoStateBy} = state ;
152- var components = state . geoJson . features . map ( ( feature ) => {
151+ var elements = state . geoJson . features . map ( ( feature ) => {
153152 var { properties} = feature ;
154153 var result = geometryToComponentWithLatLng ( feature . geometry ) ;
155- var Component = result . Component ;
156- delete result . Component ;
154+ var ElementClass = result . ElementClass ;
155+ delete result . ElementClass ;
157156 if ( properties . isCenter ) {
158- Component = Map ;
157+ ElementClass = Map ;
159158 result . center = result . position ;
160159 delete result . position ;
161160 }
162161
163- var geoStatesOfFeature = geoStateBy [ feature . id ] || { } ;
164- if ( geoStatesOfFeature . visible === false ) {
162+ var { visible , child , ... geoStatesOfFeature } = geoStateBy [ feature . id ] || { } ;
163+ if ( false === visible ) {
165164 return null ;
166165 }
167- var { style} = properties ;
168- if ( style ) {
169- style = update ( properties . style , {
170- $merge : result
171- } ) ;
172- } else {
173- style = result ;
174- }
175166
176- if ( geoStatesOfFeature ) {
177- style = update ( style , {
178- $merge : geoStatesOfFeature
179- } ) ;
180- }
181- if ( style . child ) {
182- var { ChildComponent} = result ;
183- delete result . ChildComponent ;
184- return Component ( style , ChildComponent ( style . child ) ) ;
185- }
186- return Component ( style ) ;
167+ return < ElementClass { ...properties . style } { ...result } { ...geoStatesOfFeature } >
168+ { child ? < result . ChildElementClass { ...child } /> : null }
169+ </ ElementClass > ;
187170 } ) ;
188171
189172 return React . DOM . div ( {
190173 style : {
191174 height : "100%"
192175 }
193- } , components ) ;
176+ } , elements ) ;
194177 }
195178} ) ;
196179
197180
198- var bodyRef = React . renderComponent (
181+ var bodyComponent = React . render (
199182 < Body initialGeoJson = { require ( "./geojson" ) } /> ,
200183 document . getElementById ( "react-root" )
201184) ;
0 commit comments