@@ -22,6 +22,7 @@ import { useCallback, useEffect, useState } from "react";
2222import { tileserverDomain } from "@macrostrat-web/settings" ;
2323import "./main.styl" ;
2424import { BlankImage , Image } from "../index" ;
25+ import { pipeNodeStream } from "vike/dist/esm/node/runtime/html/stream" ;
2526
2627export function Page ( ) {
2728 return h (
@@ -141,8 +142,34 @@ function FeatureDetails() {
141142
142143 if ( result == null ) return h ( Spinner ) ;
143144 result = result . success . data ;
145+ console . log ( "result:" , result )
146+
147+ checkins = createCheckins ( result , mapRef , true ) ;
148+
149+ return h ( "div" , { className : 'checkin-container' } , [
150+ h ( 'div' , checkins )
151+ ] ) ;
152+ }
153+
154+ function createCheckins ( result , mapRef , showPin ) {
155+ let checkins = [ ] ;
156+ let map = mapRef ?. current ;
144157
145158 result . forEach ( ( checkin ) => {
159+ let pin = null ;
160+
161+ if ( showPin ) {
162+ pin = h ( Image ,
163+ { src : "marker_red.png" ,
164+ className : "marker" ,
165+ onClick : ( ) => {
166+ console . log ( "clicked at: " , checkin . lat + " " + checkin . lng ) ;
167+ map . flyTo ( { center : [ checkin . lng , checkin . lat ] , zoom : 12 } ) ;
168+ }
169+ } )
170+ }
171+
172+
146173 // format rating
147174 let ratingArr = [ ] ;
148175 for ( var i = 0 ; i < checkin . rating ; i ++ ) {
@@ -156,11 +183,12 @@ function FeatureDetails() {
156183
157184 if ( imageExists ( "https://rockd.org/api/v1/protected/image/" + checkin . person_id + "/thumb_large/" + checkin . photo ) ) {
158185 image = h ( BlankImage , { className : 'observation-img' , src : "https://rockd.org/api/v1/protected/image/" + checkin . person_id + "/thumb_large/" + checkin . photo } ) ;
186+ } else {
187+ image = h ( Image , { className : 'observation-img' , src : "rockd.jpg" } ) ;
159188 }
160189
161190
162- let temp = h ( 'a' , { className : 'checkin-link' , href : "/dev/test-site/checkin?checkin=" + checkin . checkin_id } , [
163- h ( 'div' , { className : 'checkin' } , [
191+ let temp = h ( 'div' , { className : 'checkin' } , [
164192 h ( 'div' , { className : 'checkin-header' } , [
165193 h ( 'h3' , { className : 'profile-pic' } , h ( BlankImage , { src : "https://rockd.org/api/v2/protected/gravatar/" + checkin . person_id , className : "profile-pic" } ) ) ,
166194 h ( 'div' , { className : 'checkin-info' } , [
@@ -169,19 +197,32 @@ function FeatureDetails() {
169197 h ( 'p' , "Near " + checkin . near ) ,
170198 h ( 'h3' , { className : 'rating' } , ratingArr ) ,
171199 ] ) ,
200+ pin ,
172201 ] ) ,
173202 h ( 'p' , { className : 'description' } , checkin . notes ) ,
174- image
175- ] ) ,
176- ] ) ;
203+ h ( 'a' , { className : 'checkin-link' , href : "/dev/test-site/checkin?checkin=" + checkin . checkin_id , target : "_blank" } , [
204+ image ,
205+ h ( 'div' , { className : "image-details" } , [
206+ h ( 'h1' , "Details" ) ,
207+ h ( Image , { className : 'details-image' , src : "explore/white-arrow.png" } )
208+ ] )
209+ ] ) ,
210+ h ( 'div' , { className : 'checkin-footer' } , [
211+ h ( 'div' , { className : 'likes-container' } , [
212+ h ( Image , { className : 'likes-image' , src : "explore/thumbs-up.png" } ) ,
213+ h ( 'h3' , { className : 'likes' } , checkin . likes ) ,
214+ ] ) ,
215+ h ( 'div' , { className : 'comments-container' } , [
216+ h ( Image , { className : 'comments-image' , src : "explore/comment.png" } ) ,
217+ h ( 'h3' , { className : 'comments' } , checkin . comments ) ,
218+ ] )
219+ ] ) ,
220+ ] ) ;
177221
178222 checkins . push ( temp ) ;
179223 } ) ;
180-
181224
182- return h ( "div" , { className : 'checkin-container' } , [
183- h ( 'div' , checkins )
184- ] ) ;
225+ return checkins ;
185226}
186227
187228function WeaverMap ( {
@@ -192,8 +233,6 @@ function WeaverMap({
192233 children ?: React . ReactNode ;
193234 mapboxToken ?: string ;
194235} ) {
195- const mapRef = useMapRef ( ) ;
196-
197236 const [ isOpen , setOpen ] = useState ( false ) ;
198237
199238 const [ type , setType ] = useState ( types [ 0 ] ) ;
@@ -268,48 +307,14 @@ function WeaverMap({
268307
269308function getSelectedCheckins ( result ) {
270309 let checkins = [ ] ;
271- console . log ( "result" , result ) ;
310+ let mapRef = useMapRef ( ) ;
272311
273312 // Selected checkin
274313 if ( result == null ) {
275314 return h ( Spinner ) ;
276315 } else {
277316 result = result . success . data ;
278- result . forEach ( ( checkin ) => {
279- // format rating
280- let ratingArr = [ ] ;
281- for ( var i = 0 ; i < checkin . rating ; i ++ ) {
282- ratingArr . push ( h ( Image , { className : "star" , src : "blackstar.png" } ) ) ;
283- }
284-
285- for ( var i = 0 ; i < 5 - checkin . rating ; i ++ ) {
286- ratingArr . push ( h ( Image , { className : "star" , src : "emptystar.png" } ) ) ;
287- }
288- let image ;
289-
290- if ( imageExists ( "https://rockd.org/api/v1/protected/image/" + checkin . person_id + "/thumb_large/" + checkin . photo ) ) {
291- image = h ( BlankImage , { className : 'observation-img' , src : "https://rockd.org/api/v1/protected/image/" + checkin . person_id + "/thumb_large/" + checkin . photo } ) ;
292- }
293-
294-
295- let temp = h ( 'a' , { className : 'checkin-link' , href : "/dev/test-site/checkin?checkin=" + checkin . checkin_id } , [
296- h ( 'div' , { className : 'checkin' } , [
297- h ( 'div' , { className : 'checkin-header' } , [
298- h ( 'h3' , { className : 'profile-pic' } , h ( BlankImage , { src : "https://rockd.org/api/v2/protected/gravatar/" + checkin . person_id , className : "profile-pic" } ) ) ,
299- h ( 'div' , { className : 'checkin-info' } , [
300- h ( 'h3' , { className : 'name' } , checkin . first_name + " " + checkin . last_name ) ,
301- h ( 'h4' , { className : 'edited' } , checkin . created ) ,
302- h ( 'p' , "Near " + checkin . near ) ,
303- h ( 'h3' , { className : 'rating' } , ratingArr ) ,
304- ] ) ,
305- ] ) ,
306- h ( 'p' , { className : 'description' } , checkin . notes ) ,
307- image
308- ] ) ,
309- ] ) ;
310-
311- checkins . push ( temp ) ;
312- } ) ;
317+ checkins = createCheckins ( result , mapRef , false ) ;
313318
314319 if ( checkins . length > 0 ) {
315320 return h ( "div" , { className : 'checkin-container' } , checkins ) ;
0 commit comments