muharremozdemir Nominatim kullanarak yapabilirsiniz:
$response = Http::get('https://nominatim.openstreetmap.org/search.php', [
'q' => 'Kozyatağı Mahallesi, Kadıköy, İstanbul',
'polygon_geojson' => 1,
'format' => 'jsonv2'
]);
Saniyede 1 istek olarak API limit var. Buna takılmamak için ise kendiniz Türkiye haritası ile Nominatim host edebilirsiniz:
docker run -it \
-e PBF_URL=https://download.geofabrik.de/europe/turkey-latest.osm.pbf \
-e REPLICATION_URL=https://download.geofabrik.de/europe/turkey-updates/ \
-p 8080:8080 \
--name nominatim \
mediagis/nominatim:4.4
ayağa kalktıktan sonra
$response = Http::get('http://localhost:8080/search.php', [
'q' => 'Kozyatağı Mahallesi, Kadıköy, İstanbul',
'polygon_geojson' => 1,
'format' => 'jsonv2'
]);
Bu size şu şekilde bir çıktı verir:
[
{
"place_id": 83198860,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
"osm_type": "relation",
"osm_id": 8852697,
"lat": "40.9685129",
"lon": "29.0924226",
"category": "boundary",
"type": "administrative",
"place_rank": 16,
"importance": 0.26443130976830337,
"addresstype": "suburb",
"name": "Kozyatağı Mahallesi",
"display_name": "Kozyatağı Mahallesi, Kadıköy, İstanbul, Marmara Bölgesi, 34742, Türkiye",
"boundingbox": [
"40.9603994",
"40.9772495",
"29.0870869",
"29.1046816"
],
"geojson": {
"type": "Polygon",
"coordinates": [
[
[
29.0870869,
40.9665647
],
[
29.0871513,
40.9664027
],
[
29.0872961,
40.9660422
],
[
29.08739,
40.9657627
],
[
29.0874812,
40.9656878
],
[
29.0879372,
40.9651592
],
[
29.0886077,
40.9643814
],
[
29.0889993,
40.9639561
],
[
29.0893319,
40.96363
],
[
29.0895224,
40.9634437
],
[
29.0897638,
40.963235
],
[
29.0903753,
40.9628988
],
[
29.0913355,
40.9623114
],
[
29.092108,
40.9618334
],
[
29.0927195,
40.9615094
],
[
29.0932774,
40.9610314
],
[
29.0939265,
40.9603994
],
[
29.0958416,
40.9617443
],
[
29.0968931,
40.9626193
],
[
29.0971881,
40.9627003
],
[
29.0976012,
40.9628543
],
[
29.0984058,
40.963235
],
[
29.099189,
40.9637171
],
[
29.0997845,
40.9640695
],
[
29.1001224,
40.9642194
],
[
29.100455,
40.9643409
],
[
29.1013026,
40.9645556
],
[
29.1017318,
40.9646326
],
[
29.1023862,
40.9646569
],
[
29.1028368,
40.9646569
],
[
29.1038561,
40.9644989
],
[
29.1040224,
40.9647824
],
[
29.104194,
40.9650012
],
[
29.1043711,
40.9653009
],
[
29.1046816,
40.9656787
],
[
29.1038393,
40.9667737
],
[
29.1037013,
40.966993
],
[
29.1035382,
40.9672522
],
[
29.1034769,
40.9673496
],
[
29.1031597,
40.9678536
],
[
29.1024036,
40.9692511
],
[
29.1018094,
40.9703539
],
[
29.1005465,
40.9731641
],
[
29.0983247,
40.9765733
],
[
29.0981333,
40.976867
],
[
29.0979551,
40.9771865
],
[
29.0979186,
40.9772495
],
[
29.0972739,
40.9768201
],
[
29.096995,
40.9765366
],
[
29.0967804,
40.9763017
],
[
29.0964854,
40.9759372
],
[
29.0963459,
40.9757226
],
[
29.0961152,
40.9752366
],
[
29.0958095,
40.9746048
],
[
29.0954071,
40.9738433
],
[
29.0952998,
40.9734748
],
[
29.0950745,
40.9736935
],
[
29.0946883,
40.9739446
],
[
29.0942377,
40.9741471
],
[
29.0935296,
40.9742807
],
[
29.0932989,
40.9740539
],
[
29.0929556,
40.9737826
],
[
29.0926391,
40.973491
],
[
29.0917486,
40.9724987
],
[
29.091416,
40.9720531
],
[
29.0905738,
40.9709069
],
[
29.0902251,
40.9705221
],
[
29.08934,
40.9694528
],
[
29.0889108,
40.9689141
],
[
29.088251,
40.9681566
],
[
29.0879399,
40.967545
],
[
29.0876877,
40.9671399
],
[
29.0874463,
40.9668564
],
[
29.0870869,
40.9665647
]
]
]
}
}
]
geojson alanı istedğiniz poligon verisi. Test etmek için bunu https://geojson.io/ adresinde sağdaki alana yapıştırabilirsiniz:
{
"type": "Polygon",
"coordinates": [
[
[
29.0870869,
40.9665647
],
[
29.0871513,
40.9664027
],
[
29.0872961,
40.9660422
],
[
29.08739,
40.9657627
],
[
29.0874812,
40.9656878
],
[
29.0879372,
40.9651592
],
[
29.0886077,
40.9643814
],
[
29.0889993,
40.9639561
],
[
29.0893319,
40.96363
],
[
29.0895224,
40.9634437
],
[
29.0897638,
40.963235
],
[
29.0903753,
40.9628988
],
[
29.0913355,
40.9623114
],
[
29.092108,
40.9618334
],
[
29.0927195,
40.9615094
],
[
29.0932774,
40.9610314
],
[
29.0939265,
40.9603994
],
[
29.0958416,
40.9617443
],
[
29.0968931,
40.9626193
],
[
29.0971881,
40.9627003
],
[
29.0976012,
40.9628543
],
[
29.0984058,
40.963235
],
[
29.099189,
40.9637171
],
[
29.0997845,
40.9640695
],
[
29.1001224,
40.9642194
],
[
29.100455,
40.9643409
],
[
29.1013026,
40.9645556
],
[
29.1017318,
40.9646326
],
[
29.1023862,
40.9646569
],
[
29.1028368,
40.9646569
],
[
29.1038561,
40.9644989
],
[
29.1040224,
40.9647824
],
[
29.104194,
40.9650012
],
[
29.1043711,
40.9653009
],
[
29.1046816,
40.9656787
],
[
29.1038393,
40.9667737
],
[
29.1037013,
40.966993
],
[
29.1035382,
40.9672522
],
[
29.1034769,
40.9673496
],
[
29.1031597,
40.9678536
],
[
29.1024036,
40.9692511
],
[
29.1018094,
40.9703539
],
[
29.1005465,
40.9731641
],
[
29.0983247,
40.9765733
],
[
29.0981333,
40.976867
],
[
29.0979551,
40.9771865
],
[
29.0979186,
40.9772495
],
[
29.0972739,
40.9768201
],
[
29.096995,
40.9765366
],
[
29.0967804,
40.9763017
],
[
29.0964854,
40.9759372
],
[
29.0963459,
40.9757226
],
[
29.0961152,
40.9752366
],
[
29.0958095,
40.9746048
],
[
29.0954071,
40.9738433
],
[
29.0952998,
40.9734748
],
[
29.0950745,
40.9736935
],
[
29.0946883,
40.9739446
],
[
29.0942377,
40.9741471
],
[
29.0935296,
40.9742807
],
[
29.0932989,
40.9740539
],
[
29.0929556,
40.9737826
],
[
29.0926391,
40.973491
],
[
29.0917486,
40.9724987
],
[
29.091416,
40.9720531
],
[
29.0905738,
40.9709069
],
[
29.0902251,
40.9705221
],
[
29.08934,
40.9694528
],
[
29.0889108,
40.9689141
],
[
29.088251,
40.9681566
],
[
29.0879399,
40.967545
],
[
29.0876877,
40.9671399
],
[
29.0874463,
40.9668564
],
[
29.0870869,
40.9665647
]
]
]
}