问题
I followed the Bing Maps docs for Zoom into Clusters. Since Microsoft only embeds a screenshot, here's a working example. When you click on a cluster, notice that the cluster itself is not updated. Just pan the map very little bit, and then the map with its clusters is refreshed.
So either the Bing Maps documentation is broken or it is a Bing Maps bug.
Any idea for a workaround, e.g. how to force a map refresh after the map has zoomed in?
The relevant code (which does not update the map/clusters) is this, especially the last line:
function clusterClicked(e) {
if (e.target.containedPushpins) {
var locs = [];
for (var i = 0, len = e.target.containedPushpins.length; i < len; i++) {
//Get the location of each pushpin.
locs.push(e.target.containedPushpins[i].getLocation());
}
//Create a bounding box for the pushpins.
var bounds = Microsoft.Maps.LocationRect.fromLocations(locs);
//Zoom into the bounding box of the cluster.
//Add a padding to compensate for the pixel area of the pushpins.
map.setView({ bounds: bounds, padding: 100 });
}
回答1:
This is a known issue that has been fixed in the experimental branch. You can try this out by adding "&branch=experimental" to the map script URL. All fixes and features in the experimental branch will be rolled into the main release branch at the end of July.
Also, just so you are aware, there are a bunch of interactive code samples for V8 available here: http://www.bing.com/api/maps/sdk/mapcontrol/isdk#overview
来源:https://stackoverflow.com/questions/38223655/zoom-into-clusters-with-bing-maps-does-not-refresh-clusters