Skip to content

Commit 196935b

Browse files
Merge pull request #52 from OCA-UFCG/add/geographic-division
Adds geographical division of states and cities
2 parents 9e80bce + 67b59f2 commit 196935b

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

src/components/MapTiff/MapTiff.tsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import "maplibre-gl/dist/maplibre-gl.css";
55
import { useCallback, useEffect, useRef, useState } from "react";
66
import { Wrapper } from "./MapTiff.styles";
77
import { IMapInfo } from "@/utils/interfaces";
8+
import {
9+
MAP_TIFF_STYLE,
10+
MAP_TIFF_BRAZIL_STATES,
11+
MAP_TIFF_BRAZIL_CITIES,
12+
} from "@/utils/constants";
813

914
const HOST_URL = process.env.NEXT_PUBLIC_HOST_URL;
1015

@@ -26,8 +31,7 @@ const MapTiff = ({
2631
if (mapContainer.current) {
2732
const newMap = new maplibregl.Map({
2833
container: mapContainer.current,
29-
style:
30-
"https://api.maptiler.com/maps/basic-v2/style.json?key=71L2QPZ0FHRofxg3QtVC",
34+
style: MAP_TIFF_STYLE,
3135
center: [-55, -15],
3236
zoom: 3.6,
3337
maxZoom: 10,
@@ -36,6 +40,36 @@ const MapTiff = ({
3640

3741
newMap.on("load", () => {
3842
newMap.addControl(new maplibregl.NavigationControl(), "bottom-left");
43+
44+
newMap.addSource("brazil-states", {
45+
type: "geojson",
46+
data: MAP_TIFF_BRAZIL_STATES,
47+
});
48+
newMap.addLayer({
49+
id: "brazil-states",
50+
type: "line",
51+
source: "brazil-states",
52+
layout: {},
53+
paint: {
54+
"line-color": "#2D2D2D",
55+
"line-width": 2.5,
56+
},
57+
});
58+
newMap.addSource("brazil-cities", {
59+
type: "geojson",
60+
data: MAP_TIFF_BRAZIL_CITIES,
61+
});
62+
newMap.addLayer({
63+
id: "brazil-cities",
64+
type: "line",
65+
source: "brazil-cities",
66+
layout: {},
67+
paint: {
68+
"line-color": "#00000050",
69+
"line-width": 2,
70+
},
71+
minzoom: 6,
72+
});
3973
});
4074

4175
setMap(newMap);

src/utils/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,10 @@ export const defaultEEInfo: IEEInfo = {
221221
minScale: 0,
222222
maxScale: 1,
223223
};
224+
225+
export const MAP_TIFF_STYLE =
226+
"https://api.maptiler.com/maps/basic-v2/style.json?key=71L2QPZ0FHRofxg3QtVC";
227+
export const MAP_TIFF_BRAZIL_STATES =
228+
"https://raw.githubusercontent.com/OCA-UFCG/countries-geo-data/main/public/data/brazil-states.geojson";
229+
export const MAP_TIFF_BRAZIL_CITIES =
230+
"https://raw.githubusercontent.com/OCA-UFCG/municipal-brazilian-geodata/master/minified/cities.min.json";

0 commit comments

Comments
 (0)