Skip to content

Commit

Permalink
Merge pull request #64 from Propy/dev
Browse files Browse the repository at this point in the history
feat(LeafletMap): make pins open asset pages
  • Loading branch information
JayWelsh authored Jan 5, 2024
2 parents c9e768c + ae5da8f commit ec36928
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
Binary file added src/assets/img/map-marker-3d-compressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/map-marker-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 24 additions & 6 deletions src/components/LeafletMap.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';

import { MapContainer, TileLayer, Marker } from 'react-leaflet';
import { latLngBounds, latLng } from 'leaflet';

import MarkerClusterGroup from 'react-leaflet-cluster'

import markerIconPropyBlue from "../assets/svg/map_marker_propy_blue_stroked.svg";
// import markerIconPropyBlue from "../assets/svg/map_marker_propy_blue_stroked.svg";
import markerIconPropy3D from "../assets/img/map-marker-3d-compressed.png";
import {Icon} from 'leaflet'

import {
Expand Down Expand Up @@ -46,9 +48,9 @@ const LeafletMap = (props: PropsFromRedux & ILeafletMap) => {
// zoom = 6 = US zoom on desktop
// center = [38.171368, -95.430112] = middle area US

// let corner1 = leaflet.latLng(53.466832, -133.789535);
// let corner2 = leaflet.latLng(21.583438, -57.764142);
// let bounds = leaflet.latLngBounds(corner1, corner2);
let corner1 = latLng(85, -180);
let corner2 = latLng(-85, 180);
let bounds = latLngBounds(corner1, corner2);

return (
<MapContainer
Expand All @@ -61,7 +63,7 @@ const LeafletMap = (props: PropsFromRedux & ILeafletMap) => {
scrollWheelZoom={scrollWheelZoom}
center={center}
boundsOptions={{padding: [50, 50]}}
// maxBounds={bounds}
maxBounds={bounds}
minZoom={2}
maxBoundsViscosity={0.7}
>
Expand All @@ -72,9 +74,25 @@ const LeafletMap = (props: PropsFromRedux & ILeafletMap) => {
<MarkerClusterGroup
chunkedLoading
// iconCreateFunction={createClusterCustomIcon}
maxClusterRadius={(zoom: number) => {
if(zoom === 18) {
return 10;
}
return 80;
}}
>
{markers && markers.map((marker) =>
<Marker position={[marker.latitude, marker.longitude]} icon={new Icon({iconUrl: markerIconPropyBlue, iconSize: [25, 41], iconAnchor: [12, 41]})}>
<Marker
position={[marker.latitude, marker.longitude]}
icon={new Icon({iconUrl: markerIconPropy3D, iconSize: [50, 50], iconAnchor: [25, 50]})}
eventHandlers={{
click: (e) => {
if(marker?.link) {
window.open(`${window.location.origin}/#/${marker.link}`, '_blank');
}
},
}}
>
{/* <Popup>
A pretty CSS3 popup. <br /> Easily customizable.
</Popup> */}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReserveAnAddressHomeBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ const ReserveAnAddressHomeBanner = (props: PropsFromRedux) => {
if(nftRecord.longitude && nftRecord.latitude && (renderResults.length < maxEntries)) {
renderResults.push({
latitude: Number(nftRecord.latitude),
longitude: Number(nftRecord.longitude)
longitude: Number(nftRecord.longitude),
link: `token/${nftRecord.network_name}/${nftRecord.asset_address}/${nftRecord.token_id}`,
});
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface INFTRecord {
export interface ICoordinate {
longitude: number
latitude: number
link: string
}

export interface IPagination {
Expand Down Expand Up @@ -159,6 +160,9 @@ export interface INFTCoordinateResponse {
export interface INFTCoordinateEntry {
longitude: string;
latitude: string;
asset_address: string;
token_id: string;
network_name: string;
}

export interface IOwnedBalancesResult {
Expand Down Expand Up @@ -222,6 +226,7 @@ export interface IOfferRecord {
export interface ILeafletMapMarker {
longitude: number;
latitude: number;
link?: string;
}

export interface IHorizontalScrollingTextEntry {
Expand Down

0 comments on commit ec36928

Please sign in to comment.