@@ -4,7 +4,7 @@ import {MapContainer, Polyline, Popup, TileLayer} from "react-leaflet";
44import Marker from 'react-leaflet-enhanced-marker' ;
55import Icon from "react-materialize/lib/Icon" ;
66
7- class NeoTestReport extends NeoReport {
7+ class NeoMapReport extends NeoReport {
88 // Per pixel, scaling factors for the latitude/longitude mapping function.
99 widthScale = 3.35 ;
1010 heightScale = 6.7 ;
@@ -27,12 +27,25 @@ class NeoTestReport extends NeoReport {
2727 if ( this . state . data ) {
2828 this . state . data . forEach ( record => {
2929 Object . values ( record ) . forEach ( v => {
30- if ( v . identity && v . properties ) {
31- console . log ( v )
30+ if ( v . identity && v . properties && v . properties . latitude && v . properties . longitude ) {
31+ let lat = parseFloat ( v . properties . latitude ) ;
32+ let long = parseFloat ( v . properties . longitude ) ;
33+ if ( ! isNaN ( lat ) && ! isNaN ( long ) ) {
34+ this . state . nodesAndPositions . push ( { pos : [ lat , long ] , node : v } )
35+ }
36+ } else if ( v . identity && v . properties && v . properties . lat && v . properties . long ) {
37+ let lat = parseFloat ( v . properties . lat ) ;
38+ let long = parseFloat ( v . properties . long ) ;
39+ if ( ! isNaN ( lat ) && ! isNaN ( long ) ) {
40+ this . state . nodesAndPositions . push ( { pos : [ lat , long ] , node : v } )
41+ }
42+ } else if ( v . identity && v . properties ) {
3243 Object . values ( v . properties ) . forEach ( p => {
44+ // We found a property that holds a Neo4j point object
3345 if ( p . srid && p . x && p . y ) {
34- console . log ( [ p . x , p . y ] )
35- this . state . nodesAndPositions . push ( { pos : [ p . y , p . x ] , node : v . properties } )
46+ if ( ! isNaN ( p . x ) && ! isNaN ( p . y ) ) {
47+ this . state . nodesAndPositions . push ( { pos : [ p . y , p . x ] , node : v } )
48+ }
3649 }
3750 } )
3851 }
@@ -80,8 +93,8 @@ class NeoTestReport extends NeoReport {
8093 this . state . nodesAndPositions . map ( i =>
8194 < Marker position = { i . pos }
8295 icon = { < div style = { { color : colors [ 0 ] } } > < Icon className = "close" > place</ Icon > </ div > } >
83- < Popup > < code > { Object . keys ( i . node ) . map ( key =>
84- < pre > { key + ": " + i . node [ key ] + "\n" } </ pre > ) } </ code > </ Popup >
96+ < Popup > < h6 > { i . node . labels . map ( b => b + " " ) } </ h6 > < code > { Object . keys ( i . node . properties ) . map ( key =>
97+ < pre > { key + ": " + i . node . properties [ key ] + "\n" } </ pre > ) } </ code > </ Popup >
8598 </ Marker > ) : < div > </ div >
8699 let lines = < div > </ div > // [<Polyline key={0} positions={[this.state.pos1, this.state.pos2]} color={colors[0]}/>];
87100
@@ -116,4 +129,4 @@ class NeoTestReport extends NeoReport {
116129 }
117130}
118131
119- export default ( NeoTestReport ) ;
132+ export default ( NeoMapReport ) ;
0 commit comments