Spatial Query with GitSpatial

24 views
Skip to first unread message

Gianni Cristian

unread,
Nov 11, 2013, 4:53:25 AM11/11/13
to leaflet-ve...@googlegroups.com
Dear All,

I'm working with leaflet+GitSpatial. I have points on a map and I want to use a spatial query to load them on the map, on a click. 

I have done something like this but it is completely bad!!
 
            var popup = L.popup();

            function onMapClick(e) {
                popup
                    .setLatLng(e.latlng)
                    .setContent("You clicked the map at " + e.latlng.toString()+"     "+ urlgeo)
                    .openOn(map);
                
                var geojsonURL = "http://gitspatial.com/api/v1/Solimyr/WebGIS/Equake_12_13.geojson?lat="+e.latlng.lat.toString()+"lon="+e.latlng.lng.toString()+"&distance=3000000";
                var geojsonTileLayer = new L.TileLayer.GeoJSON(geojsonURL);
                map.addLayer(geojsonTileLayer);
        
                    //urlgeo = "http://gitspatial.com/api/v1/Solimyr/WebGIS/Equake_12_13.geojson?lat=4.780&lon=-0.024&distance=3000";
            }

            map.on('zoomend', onZoomend);
            function onZoomend(){
            if(map.getZoom()>=5)
             {map.on('click', onMapClick);
            }
            if(map.getZoom()< 5)
             {map.off('click', onMapClick);
            }
            };
 
It works but it is really slow. My question is if you know a better way and, actually, if I could get the number of geojson elements within the query. I'm thinking to use the number in a leaflet vector layer poput template.

I have used TileLayer plugin (https://github.com/glenrobertson/leaflet-tilelayer-geojson/) but there is a smartest way. I have also found a topic that explain how to load from URL (https://github.com/Leaflet/Leaflet/issues/420) but I didn't understand how to write (cause my noob experience!!!)

Thanks All!

P.S. Do you know a good tutorial of Ajax linked to GIS?

Reply all
Reply to author
Forward
0 new messages