1

I am trying to create the layer of the only country that is clicked earlier but without success. I managed to highlight it, but it shows me the highlighted country but also the rest of the world that I don't need. Where can I specify the coordinates of the country in question, which I find in the geojson, to create a map layer of only that country whose coordinates I load?

var tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
                            noWrap: true,
                            attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
                        }).addTo(map2);

I create that those zxy are to be changed with my coordinates, but the geojson has not only lat and long but an array of coordinates that forms the contours and borders of the country. How to integrate that array?

3
  • I think that you will have to add a negative layer of the country that you want to show. The tiles you get from OMS is just squares not accepting certain tiles is not the solution. If you want to lock the navigation as well that can be done buy limiting the bounds
    – Disco
    Commented Sep 9, 2022 at 12:43
  • You cannot actually highlight any country or feature coming from the tiled layer by clicking over it. The polygon that you have highlighted must be coming from a geojson of some type. The thing that I think you need is to filter out the geojson to get only the required feature. Is it the case?
    – majid
    Commented Sep 9, 2022 at 13:40
  • Thanks friends. Well, my tiles are formed with geojson, thanks to geojson and leaflet I was able to highlight the countries that interested me. Then world map, highlight in Africa and highlighted the countries taken from the geojson. My problem is the map below. I would like to show only one country (concrete example: open the map of Africa, click on Mali and open a new page with only the map of Mali.) Now instead I click and open the whole map of Africa with the country "highlighted" of Mali
    – Rob0ut
    Commented Sep 12, 2022 at 6:50

0

Browse other questions tagged or ask your own question.