Completed processing graphical event layer

I am utilizing the Google Maps API v3 to build a map with multiple layers that are loaded upon user request. The layers are loaded in Geojson format using the following code:

function getgeojson(json) 
    {            
        proplayer = new google.maps.Data();
        proplayer.loadGeoJson('../public/geoprop/index');
        proplayer.setStyle({  
                               fillColor: 'red',
                               strokeColor: 'red',
                               fillOpacity: 0.3,
                               strokeWeight: 1
                            });
         proplayer.setMap(map);                 
         proplayer.addListener('mouseover', function(event) {                                   
                                infoWindow.setContent(event.feature.getProperty('kta'));
                                infoWindow.setPosition(event.latLng);
                                infoWindow.open(map);
                            });     

    }

The layers consist of approximately 3.5 K polygons with simple geometries (mainly rectangular shapes) and take around 5 seconds to be fully displayed on the map. To indicate loading while the layer is rendered, I am using two functions:

ajaxindicatorstart('loading data.. please wait..');
ajaxindicatorstop();

to initiate and stop the loader. However, I am facing difficulty in detecting when the rendering is completed. I have attempted using:

proplayer.addListener( 'metadata_changed', function () {ajaxindicatorstop();}); 

and

google.maps.event.addListener(map, 'idle', function() {
                                            ajaxindicatorstop();
                            }); 

suggested by other users but it was not successful. Is it possible to achieve this? Are there any alternative solutions to overcome this issue?

Thank you in advance

Answer №1

One potential method to consider:

  1. Instead of using loadGeoJson, load the JSON data through AJAX
  2. Determine the number of features in the JSON file and save this value to a variable
  3. Monitor the addfeature event of the layer (more details provided at the end)
  4. Use addGeoJson to add the features to the layer

Within the addfeature handler, you can decrease the feature count that was stored in step 2. When it reaches 0, all features have been successfully added.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Use the slide bar to adjust the Angular filter value

I am diving into my very first AngularJS project and I must admit, I have zero experience with Angular. On my HTML page, I have implemented a slider bar with two handles to set a minimum and maximum value. Here is the snippet of code where this functionali ...

Rotation snapping feature 'control.setRotationSnap' in TransformControls.js (Three.js) is not functioning properly

Attempting to utilize the functionality of "control.setRotationSnap" from the script "TransformControls.js", but unfortunately, it is not working as expected. After conducting some research, I came across a forum post suggesting that the code might not be ...

What is the best approach for determining the most effective method for invoking a handler function in React?

As a newcomer to React, I am navigating through the various ways to define callback functions. // Approach 1 private handleInputChange = (event) => { this.setState({name: event.target.value}); } // Approach 2 private handleInputChange(event){ t ...

Error: When executing the npm run build command, I encountered a TypeError stating that Ajv is not a

I keep encountering an issue whenever I try to execute npm run build error: /node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/validate.js:66 const ajv = new Ajv({ ^ TypeError: Ajv is not a constructor at Object.<anon ...

Creating a dataset for D3 in JavaScript: A step-by-step guide

I am attempting to construct a graph similar to this: https://i.sstatic.net/USdyj.png. The graph represents a dependencies tree where each node has a list of elements it depends on as children (in a list), or a simple JSON structure with name and size info ...

How can I transfer a MongoDB collection to an EJS file in the form of a sorted list?

I have successfully displayed the collection as a json object in its own route, but now I want to show the collection in a list under my index.ejs file (I'm still new to ejs and MongoDB). Below is the code that allows me to view the json object at lo ...

Setting Authorization with username, password, and domain in Angular 2 HTTP Request

I am facing an issue with calling an API method hosted on another machine using Angular 2 component with Http. When accessing the API from a browser, I can connect by entering a username and password as shown below: https://i.stack.imgur.com/JJqpC.png Ho ...

Creating a table from data in your database using Firebase

Can anyone guide me on how to craft a data table similar to this exampleusing information from a Firebase database like shown here The table should have columns for ID, Title, Number of Answers, Correct Answer, and Type. It would be best if this can be ac ...

Stop the setTimeout function after redirecting in the controller

I am experiencing an issue with my AJAX call as it keeps triggering my controller repeatedly. AJAX function <script type="text/javascript> var stopTime =0; var scoreCheck = function () { $.ajax({ url: "<?php echo 'http:// ...

Attempting to forward an image in a node-js/express application

I am facing an issue with a broken image link when trying to access it through Express: app.get('/fileThumbnail', function(req, res) { var url = proxiedURL +"?" + querystring.stringify(req.query); logger.info('/fileThumbnail going to url& ...

Utilize Three.js to Add Depth to 2D Images with Extrusion

After searching online, I have been unable to find a method to extrude a colored image in Three.js. My goal is to create a design similar to a Minecraft item where the image is used to generate an extruded geometry. An example of what I'm trying to ac ...

Is It Possible to Save Data to Local Storage Using Vue.js?

I am currently working on storing data using Vue.js and local storage. By writing localStorage.set('something', 5) in my main.js file, I can view the data in the Chrome dev tools under the 'Storage' section in the 'Application&apo ...

The filtering function stops working after the initial use

As I develop an app using React and Redux, my goal for the following code snippet is to function as a reducer within the main application. I have imported a filterData function, which works seamlessly the first time any Action type is selected. However, it ...

Remove console.log and alert statements from minified files using uglifyjs-folder

Currently, I am minifying multiple files in a directory using the uglifyjs-folder feature within my npm configuration in the package.json file as shown below: "uglifyjs": "uglifyjs-folder js -eyo build/js" The process is effectively minifying all the fil ...

Two events in an arrow-guided grid including a text box (jQuery)

I have successfully implemented an editable table using jQuery where users can click on a cell to input text. The goal now is to enable the use of ARROW keys for quick navigation within the table. Below is my current code: $( function () { $( "td" ). ...

Retrieve the specific item from an object array using the designated key

I am working with an array of objects and my goal is to retrieve the object that has the key "Z". While I could iterate through the array, checking each key one by one until finding a match, I believe there might be a more efficient solution than my curre ...

Struggling to align images side by side using HTML and CSS along with figcaption and buttons

Adding buttons below images on my webpage is proving to be a bit challenging. I tried using the figcaption tag, but it resulted in the images stacking on top of each other instead of side by side. **My HTML:** <section class="mostpurch"> ...

Error alert: The function is declared but appears as undefined

Below is the javascript function I created: <script type="text/javascript"> function rate_prof(opcode, prof_id) { $.ajax({ alert('Got an error dude'); type: "POST", url: "/caller/", data: { ...

Show picture in web browser without the file extension

Is there a way to display an image in the browser without the file extension, similar to how Google and Unsplash do it? For example: Or like this: ...

The post body is incomplete and is lacking the necessary parameter "To" that

It seems there might be a configuration issue either in the header or the body. Should I make changes to the headers or is it possible that the body is misconfigured? const axios = require('axios'); const url = '/my_url'; const aut ...