Heatmap for Arcgisjsapi

Source: Internet
Author: User

Use the Heatmap plugin in an ArcGIS for JS API environment.

Because the latest heatmap does not provide for ARCGISJSAPI plug-ins, too lazy to study the new version of the code, so here is the old version of the heatmap.

However, the old version of the plugin has a problem, that is, when the point aggregation calculation is grouped according to the original coordinate points, which causes when the coordinate value of the precision is very high, all the points will be separate as a group, no matter how close the two points. The end result is that each point on the map will be the highest value, and the map looks like this.

The workaround is to intervene in the Parseheatmapdata method to group the screen coordinates instead of the more precise latitude and longitude (if you want a larger tolerance, you can also round the screen coordinates and increase the tolerance by 10 times times).

Modified Parseheatmapdata method

Parseheatmapdata:function(datapoints) {//variables            varI, Parseddata, datapoint; //if data points exist            if(datapoints) {//Create parsed data objectParseddata ={max:0, data: []}; if(! This. Config.uselocalmaximum) {Parseddata.max= This. GlobalMax; }                                 //For each data point                 for(i = 0; i < datapoints.length; i++) {                    //Create Geometry PointVdatapoint =Esri.geometry.Point (datapoints[i].geometry); Datapoint= Esri.geometry.toScreenGeometry ( This. _map.extent, This. _map.width, This. _map.height, Vdatapoint); //Datapoint                    //If array value is undefined                    if(!Parseddata.data[datapoint.x]) {                        //Create empty array valueParseddata.data[datapoint.x] = []; }                    //array value array is undefined                    if(!Parseddata.data[datapoint.x][datapoint.y]) {                        //create object in arrayPARSEDDATA.DATA[DATAPOINT.X][DATAPOINT.Y] = {}; //if count is defined in Datapoint                        if(Datapoint.hasownproperty (' count ')) {                            //Create array value with Count of Count set in DatapointParseddata.data[datapoint.x][datapoint.y].count =Datapoint.count; } Else {                            //Create array value with Count of 0Parseddata.data[datapoint.x][datapoint.y].count = 0; }                    }                    //Add 1 to the CountParseddata.data[datapoint.x][datapoint.y].count + = 1; //Store datapoint varParseddata.data[datapoint.x][datapoint.y].datapoint =Vdatapoint; //if Count is greater than current Max                    if(Parseddata.max <Parseddata.data[datapoint.x][datapoint.y].count) {                        //set Max to this countParseddata.max =Parseddata.data[datapoint.x][datapoint.y].count; if(! This. Config.uselocalmaximum) {                             This. GlobalMax =Parseddata.data[datapoint.x][datapoint.y].count; }                    }                }                //convert parsed data into HEATMAP plugin formatted data                 This. Convertheatmapdata (Parseddata); }        },

The modified effect:

Heatmap for Arcgisjsapi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.