Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function App() {
)
.then((res) => res.json())
.then((jsonRes) => {
console.log(jsonRes);
const newPins = jsonRes.resourceSets[0].resources.map(
(resource) => {
if (!resource.geocodePoints) {
Expand Down
13 changes: 13 additions & 0 deletions src/components/BingMapsReact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function BingMapsReact({
mapOptions,
onMapReady,
pushPins,
clusterPins,
pushPinsWithInfoboxes,
viewOptions,
width,
Expand Down Expand Up @@ -129,6 +130,16 @@ export default function BingMapsReact({
addPushpins(pushPins, map.current, Maps);
}

if (clusterPins) {
Maps.loadModule('Microsoft.Maps.Clustering', function () {
var pushpins = clusterPins.map(function (location) {
return new Maps.Pushpin(location.center, location.options)
})
var clusterLayer = new Maps.ClusterLayer(pushpins, { gridSize: 100 })
map.current.layers.insert(clusterLayer)
})
}

// add infoboxes, if any
if (pushPinsWithInfoboxes) {
const infobox = new Maps.Infobox(map.current.getCenter(), {
Expand All @@ -150,6 +161,7 @@ export default function BingMapsReact({
mapOptions,
onMapReady,
pushPins,
clusterPins,
pushPinsWithInfoboxes,
viewOptions,
]);
Expand Down Expand Up @@ -181,6 +193,7 @@ BingMapsReact.defaultProps = {
height: "100%",
onMapReady: null,
pushPins: null,
clusterPins: null,
pushPinsWithInfoboxes: null,
viewOptions: null,
width: "100%",
Expand Down