How to get lat and lng from district names in yii2


(Jamess) #1

Hi, I am using Yii 2 basic. I have a master table called District which stores District Id and District Name. I have created 36 entries into this table with districts. Now I am using Leaflet js for displaying these districts on a map with markers. But I don’t have latitude and longitude stored in table for displaying locations on map. So how could I get the Latitude and Longitude.


(Alexander Makarov) #2

Via reverse geocoding. But be careful using Google APIs for the purpose. Even their coordinates are copyrighted content.


(Jamess) #3

How should I load markers dynamically on map based on the district names received from the server response using ajax as my table does not contain latitude and longitude for districts. Is there any other way where I can get latitude and longitude from the district names recevied through json in ajax. Like geojson.io


(Alexander Makarov) #4

as my table does not contain latitude and longitude for districts

Pre-compute it using one of reverse geocoding services.