Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle large numbers of pushpins in Bing Maps

I am using Bing Maps with Ajax and I have about 80,000 locations to drop pushpins into. The purpose of the feature is to allow a user to search for restaurants in Louisiana and click the pushpin to see the health inspection information.

Obviously it doesn't do much good to have 80,000 pins on the map at one time, but I am struggling to find the best solution to this problem. Another problem is that the distance between these locations is very small (All 80,000 are in Louisiana). I know I could use clustering to keep from cluttering the map, but it seems like that would still cause performance problems.

What I am currently trying to do is to simply not show any pins until a certain zoom level and then only show the pins within the current view. The way I am currently attempting to do that is by using the viewchangeend event to find the zoom level and the boundaries of the map and then querying the database (through a web service) for any points in that range.

It feels like I am going about this the wrong way. Is there a better way to manage this large amount of data? Would it be better to try to load all points initially and then have the data on hand without having to hit my web service every time the map moves. If so, how would I go about it?

I haven't been able to find answers to my questions, which usually means that I am asking the wrong questions. If anyone could help me figure out the right question it would be greatly appreciated.

like image 428
Justin Avatar asked Apr 18 '12 21:04

Justin


People also ask

Where does Bing Maps get its data?

Microsoft's mapping service Bing Maps has announced a change in its base map data source. The Bing Maps Platform, which is typically powered by multiple data providers, will now get its base map data from TomTom for all the regions across the world save China, Japan, and South Korea.

Can you edit Bing Maps?

To do that, you can use Map Style Sheet Editor with the Bing Maps V8 Web Control and the Bing Maps REST services. Released back in July, the Map Style Sheet Editor makes it possible for you to customize the appearance of your map so that it integrates elegantly into your existing design.

What are Bing Maps transactions?

Bing Maps Transaction: A Bing Maps transaction occurs any time a service request is made. For example, some of the more common services used that incur transactions are: Bing Maps Geocoding, Routing, and Imagery service, Bing Spatial Data Service Query .

What can you do with Bing Maps?

The Bing Maps REST Services uses REST URLs to perform tasks such as creating a map with pushpins, geocoding an address, retrieving imagery metadata or calculating a route. The Bing Spatial Data Services uses REST URLs to geocode and reverse-geocode large sets of spatial data and to create and query data sources.


1 Answers

Well, I've implemented a slightly different approach to this. It was just a fun exercise, but I'm displaying all my data (about 140.000 points) in Bing Maps using the HTML5 canvas.

I previously load all the data to the client. Then, I've optimized the drawing process so much that I've attached it to the "Viewchange" event (which fires all the time during the view change process).

I've blogged about this. You can check it here.

My example does not have interaction on it but could be easily done (should be a nice topic for a blog post). You would have thus to handle the events manually and search for the corresponding points yourself or, if the amount of points to draw and/or the zoom level was below some threshold, show regular pushpins.


Anyway, another option, if you're not restricted to Bing Maps, is to use the likes of Leaflet. It allows you to create a Canvas Layer which is a tile-based layer but rendered in client-side using HTML5 canvas. It opens a new range of possibilities. Check for example this map in GisCloud.


Yet another option, although more suitable to static data, is using a technique called UTFGrid. The lads that developed it can certainly explain it better than me, but it scales for as many points as you want with a fenomenal performance. It consists on having a tile layer with your info, and an accompanying json file with something like an "ascii-art" file describing the features on the tiles. Then, using a library called wax it provides complete mouse-over, mouse-click events on it, without any performance impact whatsoever.

I've also blogged about it.

like image 84
psousa Avatar answered Sep 22 '22 05:09

psousa