Hot answers tagged

4

The first "A" in "AJAX" stands for "asynchronous", which means that the application flow continues before the server sends back the response (I think "fire and forget" is a useful analogy). In your example, hiding the mask happens immediately after the request is made (not after it completes). The code you want to execute after the request completes must be ...


4

Here is how I solved my own problem: var pointLayer = new OpenLayers.Layer.Vector("POI Markers", {projection: "EPSG:4326"}); $.getJSON('json/DATA.json', function(data) { $.each(data.POI, function() { var pointFeatures = []; var px = this.longitude; var py = this.latitude; // Create a lonlat instance and transform it to the map projection. ...


4

The following is the fallback function for data loading: layer_kos.on('data:loaded', function() { }) More can be found in the doc


3

In your globalArrayJobsCID, you just push the cid, not the associated value. And I guess you actually want to show that value (i.e. an item from your data), not the cid itself (or not only that). Furthermore, in your 2nd step, when you loop through your globalArrayJobsCID to find matches with each polygon / grid cell, you override the layer popup. This may ...


3

Plain leaflet does not offer asynchronous loading from external resources. If you really want to craft all this youself, you could use the plain XMLHTTPRequest http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp object and craft all the functionality you need with it. But I think it would be useless. Just include jquery and have all the ...


3

See code example Leaflet users map https://github.com/bmcbride/leaflet-users-map by Bryan McBride. There is used SQLite DB, but her easy replace on MySQL.


3

tileBounds Try researching that link. Also: Tile Layer Bounding Box Example Or modify errorTileUrl to help your cause. Perhaps try errorTileUrl: ""


3

Well, from firebug console, it seems the returned content is not pure json but a mix of xml and json .... Be sure the url passed in ajax call return pure json and it will work fine.


3

The problem is in the url string. It had two problems: Additional comma at the end of layers parameter as suggest by @Stefan in comments &layers=workspace%3AlayerA,workspace%3AlayerB,workspace%3AlayerC,workspace%3AlayerD,workspace%3AlayerE,workspace%3AlayerF,workspace%3AlayerE, Main problem was the missing query_layers parameter as it is a must ...


2

To expand on my comment, let me talk about a similar application I had developed to showcase results of an election. There was some data which was updated periodically in the database (i.e. the Results), while most of the data, including the Geometry did not change. My JavaScript Application used a static GeoJSON file for the static data and Geometry. I had ...


2

I think the problem is that your request is malformed and so GeoServer is returning you a service exception as XML. Looking at your request it looks like your CQL filter parameter is missing a final bracket. The other issue is that there should not be a space between the word POINT and the opening bracket. And finally the filter function is INTERSECTS and ...


2

Change map.addLayer(layer); to map.addLayers([layer]);


2

Did you enabled geoserver JSONP settings in web.xml /geoserver/WEB-INF/web.xml contains settings like this: <context-param> <param-name>ENABLE_JSONP</param-name> <param-value>true</param-value> </context-param> You should change ENABLE_JSONP as true


2

If you get results from your php code, copy that json result into the tester on geojson.io or geojsonlint.com to check the format, once you confirm the data, take a close look to the "coordinates" values, sometimes PostGIS brings that data in a format that leaflet cant draw. If coordinates are alright, then someting in the code html code is the problem. One ...


2

After seeking for a more broad (jQuery and AJAX related) answer here I assigned to my jsonpCallbacks unique values, like the following: //JSON request $.ajax({ url: "http://localhost:8080/geoserver/PastDenver/ows?service=WFS&version=2.0.0&request=GetFeature&typeName=PastDenver:dataset3&maxFeatures=300&...


2

The state of the IdentityManager can be retrieved using the toJson() method. That should give you the token to use with the ajax calls.


2

In v3.6.0 constructor: new ol.tilegrid.XYZ(...) has been replace by static function: ol.tilegrid.createXYZ(...) See ol3 upgrade notes.


2

You're creating new markers right here: overlays[destination] = new L.GeoJSON(null, { Just don't. Refer to the existing instances instead.


2

From your above additional code, it looks like you are loading Leaflet.markercluster script before Leaflet script: <script src="leaflet.markercluster-src.js"> <script src="http://code.jquery.com/jquery-1.12.0.min.js"> <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"> You should rather load it after: <script src="http://...


2

I think it is a asynchronous issue: your function $.getJSON does not ends before the remainder of the code is executed. Therefore, the object people actually doesn't exist when your code want to use it. A solution is to put all the remainder of your code into the function $.getJSON: $.getJSON( /*All your code here */) but this solution won't work if ...


2

Your "working" Pen has unassigned qom variable, and L.GeoJSON.AJAX('#loadButton') is definitely not going to work, as '#loadButton' URL will not provide a valid JSON data. The thing you must understand is that AJAX is made to retrieve network resources. Until some point it was possible to use it to read local data (on your file system), only if the page was ...


2

It turns out that I think JQuery is re-using the callback function name "getJson". To avoid this, I create callback function names for each layer using the actual GeoServer layer name. My layer names are in the "layers" array in the form WORKSPACE NAME:LAYER NAME. So in the above code, wherever I referenced the callback function "getJson" I replaced it ...


2

I had similar issue. Did exactly like you did. Later, I used GET and solved the issue. You just need to use encodeURI() before passing your json as the spec parameters. Try following: $("#export-pdf").click(function(){ var json = encodeURI(JSON.stringify(specs)); $.ajax( { url:'http://localhost:9090/geoserver/pdf/print.pdf?spec=' + json, ...


2

Most probably your data is still string type, which is not suitable as input to Leaflet Marker factory L.marker. From your code and data sample, jQuery $.get performs an AJAX request and treats the response as text (in your data argument), that you refactor using the string method split. Therefore your markers array contains string representations: '[49....


2

Here is a working example, for points. I used JQuery to get the data from my external GeoJSON file. Note You need it running from a server or localhost if your using an external data file. In this case my GeoJSON file is in the same folder as my html file. http://www.gistechsolutions.com/leaflet/DEMO/Drink/Drink.html My GeoJSON file: var url = 'Drink.json';...


2

One possibility would be to use setTimeout function to check when all three layers are loaded, something like this: var layer1Loaded = false; var layer2Loaded = false; var layer3Loaded = false; function checkAllLoaded() { if (layer1Loaded && layer2Loaded && layer3Loaded) { // process loaded layers } else { setTimeout(...


2

According to the docs there is a function L.Util.ajax that returns a promise. So this should work (is untested) data_layer1=L.Util.ajax(data1.geojson,{options}); data_layer2=L.Util.ajax(data2.geojson,{options}); data_layer3=L.Util.ajax(data3.geojson,{options}); Promise.all([data_layer1, data_layer2, data_layer3]).then(loadedLayers => { // The ...


2

For anybody who might be having an issue similar to me i have found a solution based on a tutorial from https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Picking.html. My solution based on this is below: function addMultipleBillboards() { Sandcastle.declare(addMultipleBillboards); var satelliteURL = '../images/sat.png'; var facilityUrl ...


2

Try something like this: var feature = yourVectorSource.forEachFeature(function(feature) { if (feature.get('id_teren') == id_teren) return feature; }); if (feature) { feature.setStyle(yourHighlightStyle); map.getView().fit(feature.getGeometry()); }


1

Use L.geojson.ajax to create a Geojson layer from php. Then you can use onEachFeature property to set the markers and use the layers builtin events to handle clicks. This way the code will be more intuitive and manageable.


Only top voted, non community-wiki answers of a minimum length are eligible