Geoapify Attribution is required message for commercial use

81 views Asked by At
  1. I am going to use Geoapify Reverse Geocode API in the node.js project. In their site they mentioned Geoapify Attribution is required. Is this mandatory for API project ?

Can I use the Free plan in commercial projects? Yes, we do not restrict that. However, you must provide an appropriate Geoapify attribution or link to our website. The attribution is added automatically to a map if you use style.json to initialize the map. Otherwise, the correct attribution is " Powered by Geoapify"

  1. Is there any alternative solution to get the country code while passing lattitute and longtitue in npm packages ?
1

There are 1 answers

2
Bench Vue On

You can use Open Street Map API

It supports shows map and reverse geolocation.

Example reverse geo API

https://nominatim.openstreetmap.org/reverse?format=json&lat=48.85341&lon=2.3488

enter image description here

I made a demo program. It shows a map and reverse geo data by node.js

Local Server using express

const express = require('express');
const axios = require('axios');
const app = express();
const port = 3000;

app.get('/map', (req, res) => {
    res.sendFile(__dirname + '/index.html');
});


app.get('/reverse', async (req, res) => {
    const lat = req.query.lat;
    const lon = req.query.lon;

    if (!lat || !lon) {
        return res.status(400).send('Latitude and longitude are required');
    }

    try {
        const response = await axios.get(`https://nominatim.openstreetmap.org/reverse`, {
            params: {
                format: 'json',
                lat: lat,
                lon: lon
            }
        });
        res.json(response.data);
    } catch (error) {
        res.status(500).send('Error occurred while fetching data');
    }
});

app.listen(port, () => {
    console.log(`Server running at http://localhost:${port}`);
});

index.html

<!DOCTYPE html>
<html>
<head>
    <title>Map and Data Display</title>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/>
    <style>
        #mapid, #data {
            float: left;
            width: 50%;
            height: 1024px;
        }
    </style>
</head>
<body>
    <div id="mapid"></div>
    <div id="data"><pre id="jsonData"></pre></div>
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
        // Function to get URL parameters
        function getURLParameter(name) {
            var params = new URLSearchParams(window.location.search);
            return params.get(name);
        }

        // Get latitude and longitude from URL parameters
        var lat = getURLParameter('lat') || 48.85341; // Default latitude
        var lon = getURLParameter('lon') || 2.3488;   // Default longitude

        // Initialize map with dynamic latitude and longitude
        var mymap = L.map('mapid').setView([lat, lon], 13);
        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            maxZoom: 19,
            attribution: '© OpenStreetMap contributors'
        }).addTo(mymap);
        L.marker([lat, lon]).addTo(mymap);

        // Fetch and display data using dynamic latitude and longitude
        axios.get('/reverse', { params: { lat: lat, lon: lon } })
            .then(response => {
                document.getElementById('jsonData').textContent = JSON.stringify(response.data, null, 2);
            })
            .catch(error => {
                console.error(error);
                document.getElementById('jsonData').textContent = "Error: " + error.message;
            });
    </script>
</body>
</html>

Access URL with latitude and longitude input parameters

http://localhost:3000/map/?lat=48.85341&lon=2.3488

Result

enter image description here

It is mimic of Geoapify server.

enter image description here