Skip to content

Commit

Permalink
no need for map ids
Browse files Browse the repository at this point in the history
  • Loading branch information
kavigupta committed Sep 2, 2024
1 parent c12776e commit 6d9fcb6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion react/src/components/article-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function ArticlePanel({ article } : { article: Article }) {
<p></p>

<div ref={map_ref}>
<Map id="map"
<Map
longname={article.longname}
related={article.related as NormalizeProto<IRelatedButtons>[]}
article_type={article.articleType}
Expand Down
1 change: 0 additions & 1 deletion react/src/components/comparison-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export function ComparisonPanel(props: { joined_string: string, universes: strin
<ComparisonMap
longnames={props.datas.map(x => x.longname)}
colors={props.datas.map((_, i) => color(i))}
id="map_combined"
basemap={{ type: "osm" }}
/>
</div>
Expand Down
11 changes: 8 additions & 3 deletions react/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { UNIVERSE_CONTEXT } from '../universe';

export interface MapGenericProps {
height?: string,
id: string,
basemap: Basemap,
}

Expand All @@ -31,11 +30,17 @@ class MapGeneric<P extends MapGenericProps> extends React.Component<P> {
private basemap_props: null | Basemap = null;
protected map: L.Map | undefined = undefined
private exist_this_time: string[] = []
private id: string;

constructor(props: P) {
super(props);
this.id = "map-" + Math.random().toString(36).substring(2);
}

render() {
return (
<div className="map-container-for-testing">
<div id={this.props.id} className="map" style={{ background: "#fff8f0", height: this.props.height || 400 }}>
<div id={this.id} className="map" style={{ background: "#fff8f0", height: this.props.height || 400 }}>
{/* place this on the right of the map */}
<div style={
{ zIndex: 1000, position: "absolute", right: 0, top: 0, padding: "1em" }
Expand Down Expand Up @@ -73,7 +78,7 @@ class MapGeneric<P extends MapGenericProps> extends React.Component<P> {
}

async componentDidMount() {
const map = new L.Map(this.props.id, {
const map = new L.Map(this.id, {
layers: [], center: new L.LatLng(0, 0), zoom: 0,
zoomSnap: this.delta, zoomDelta: this.delta, wheelPxPerZoomLevel: 60 / this.delta
});
Expand Down
1 change: 0 additions & 1 deletion react/src/components/mapper-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ function MapComponent(props: MapComponentProps) {
}}>
<div style={{ height: "90%", width: "100%" }}>
<DisplayedMap
id="mapper"
color_stat={color_stat}
filter={filter}
geography_kind={props.geography_kind}
Expand Down
4 changes: 2 additions & 2 deletions react/src/quiz/quiz-question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface QuizQuestionProps {
no_footer: boolean
quiz: { kind: "juxtastat" | "retrostat", name: number | string}
on_select: (letter: "A" | "B") => void
length: number
length: number,
}

function QuizQuestion(props: QuizQuestionProps & {
Expand Down Expand Up @@ -165,7 +165,7 @@ function JuxtastatQuizQuestion(props: QuizQuestionProps & {
{...props}
get_question={() => render_question(props.question.question)}
get_option={(letter) => props.question[`longname_${letter}`]}
get_demo={(letter) => <Map id={`map_${letter}this.props.ident`}
get_demo={(letter) => <Map
longname={props.question[`longname_${letter}`]}
basemap={{ type: "osm" }}
/>}
Expand Down

0 comments on commit 6d9fcb6

Please sign in to comment.