iag-geo / bootleaf

An open-source version of IAG's Bootleaf fork
https://demo.bootleaf.xyz
MIT License
89 stars 65 forks source link

MySQL #1

Closed Ileouleyuki closed 6 years ago

Ileouleyuki commented 6 years ago

Hye,

I used the old bootleaf and i discovered yours. Great Job !!! So, i try to migrate to bootleag-iag but i have a request. I used MySQL server side for display markers for the server side and i load it every event moveend and zoom parameters.

The MySQL Server side send geojson format and bootloeaf display it on the map.

I don't have the possibility to have a GeoServer Server, so i made the job by mysql and php.

Is it possible to specify an url (Ajax) to call with parameters in the custom.js ? ...

Thanks

Ileouleyuki commented 6 years ago

Oh !! If i build a geojson file of my differents markers save in the database. The File is TOO BIIIGGG :)

slead commented 6 years ago

Hi @Ileouleyuki, I'm glad you find it useful!

Yep, you can absolutely create a layer based on an AJAX query, and update it each time the map changes. I've done this for some of our internal maps in situations where it doesn't make sense to define the layer directly via the config.js file.

Let me know if you have any problems setting it up and I'll try to assist if I can.

Ileouleyuki commented 6 years ago

Your welcome men ;)

Ok can you post a basic configuration because i don't see what kind of layer configuration :

I think something like that

"layers": [ { "id": "myGeoJSON_MySQL", "name": "MyName", "type": "geoJSON", "cluster": true, "showCoverageOnHover": false, "minZoom": 12, "url": "http://myserver.fr/Marker/", "icon": { "iconUrl": "./img/myIcon.png", "iconSize": [24,28] }, "style": { "stroke": true, "fillColor": "#00FFFF", "fillOpacity": 0.5, "radius": 10, "weight": 0.5, "opacity": 1, "color": '#727272', }, "visible": true } }

but i don't know how to put my POST param. My POST param is the lat and lng of the map center If i don't post the param, my server will load 10 000 Markers and my map will crash and become not very user-friendly :)

Thanks

slead commented 6 years ago

Rather than trying to define a layer to slot into the config.js file, you can put something like this into the afterMapLoads function:

// Read in the values from an AJAX query 
var data = {
    "service":"WFS",
    "version":"1.0.0",
    "request":"GetFeature",
    "typeName": "loceng:vw_geocoded_repairers",
    "propertyName": "repairer_code,repairer_name,lon,lat",
    "outputFormat":"text/javascript"
  }
$.ajax({
    type: 'GET',
    url: "path_to_your_server",
    data: data,
    async: false,
    dataType: 'jsonp',
    success: function(data, jqXHR, response) {
        // do something with the response, eg add the GeoJSON as a standard Leaflet layer

    }
  });

That is, create (and trigger) the AJAX request when you need it, and manually add the results to the map in a manner similar to the Leaflet GeoJSON sample