[GIS] Display Geojson data from PHP API (http://localhost/sample.php) on google map

geojsongoogle mapsPHP

I have PHP API (http://localhost/api.php) that gives data in GeoJSON format, how can I show that GeoJSON data on Google map ?

Dragging & Dropping GeoJSON data on map is not allowed.

Best Answer

You can use Ajax and leaflet for displaying GeoJSON data. Here is a detailed example of GeoJSON in leaflet.

You have to modify 'Ajax' given below according to your php.

$.ajax({
        type: "POST",
        url: "YourPHP.php",
        dataType: 'json',
        success: function (response) {

var gj = L.geoJson(response, { style: oldStyle }).addTo(map); });

Related Question