none
Highest performance approach - Get all pushpins in view RRS feed

  • Question

  • Hello,

    Regarding the V8 controls, what is the best performing approach to get all of the currently visible pushpins on the map that are in view?

    I've seen that the clustering module has a method to get pushpins in view but I'm curious what others have done or recommend in this area.

    My goal is to have a fast way to access all visible pushpins as I will be updating a UI control with this list as the user pans around the map and the visible pushpins change. We use clustering but only in specific scenarios to reduce the number of pins displayed on the map. In other scenarios clustering is disabled on the map.

    I appreciate your time and input.

    Regards,

    Kevin

    Wednesday, June 21, 2017 7:06 PM

Answers

  • Loop through all the pushpins and store their locations in an array, if you are not updating the pushpin locations you can do this when creating the pushpins to save time later. From there you can convert the array of locations to pixels using the maps tryLocstionToPoint function. Then loop through and see if the pixel points are within the dimensions of the map. X is between 0 and the map width in pixels, y is between 0 and the map height in pixels. If a point is in the map view, use its array index to grab the pushpin from your array of pushpins as the index will be the same.

    [Blog] [twitter] [LinkedIn]

    Thursday, June 22, 2017 4:00 AM

All replies

  • Loop through all the pushpins and store their locations in an array, if you are not updating the pushpin locations you can do this when creating the pushpins to save time later. From there you can convert the array of locations to pixels using the maps tryLocstionToPoint function. Then loop through and see if the pixel points are within the dimensions of the map. X is between 0 and the map width in pixels, y is between 0 and the map height in pixels. If a point is in the map view, use its array index to grab the pushpin from your array of pushpins as the index will be the same.

    [Blog] [twitter] [LinkedIn]

    Thursday, June 22, 2017 4:00 AM
  • Awesome, thanks Ricky!
    Thursday, June 22, 2017 3:43 PM