elewin / pi-weather-station

MIT License
282 stars 61 forks source link

Another map API? #55

Open ChrisS-code opened 2 months ago

ChrisS-code commented 2 months ago

Is it possible to use a map API, other than Mapbox? I would like to use other free map API's, but no map is showing when trying.

deev3e commented 1 month ago

Yes!

You can find many free maps providers here: https://leaflet-extras.github.io/leaflet-providers/preview/

When chosen your tiles provider do some edits:

  1. Edit the file client/src/components/WeatherMap/index.js. Find <TileLayer> tag and change the url parameter there, can look something like:
     <TileLayer
        attribution='   d-map'
        url={`https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png`}
      />
  1. Now enter the pi-weather-station/client directory. You'll find the webpack configuration file there. Before you run webpack you would probably want to npm install to get needed modules. Run webpack like:
webpack --config webpack.config.js
  1. Go back to main directory, run your server (npm start), you should see your free tiles
Screenshot 2024-06-05 at 23 49 20

Just in case - quick workaround for api settings - in Settings under Maps API key enter anything

Screenshot 2024-06-05 at 23 53 04