【发布时间】:2021-04-26 20:38:05
【问题描述】:
我创建了一个叠加层,我想使用它来允许用户在地图上选择一个区域。问题是我需要将屏幕中间 300px 高度和宽度圆圈的位置映射到我绘制圆圈时有意义的位置。
这是我尝试过的:
const circle = new google.maps.Circle({
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35,
map: mapRef.current,
center: mapRef.current.getCenter(),
radius: 100000 / (mapRef.current.getZoom() * mapRef.current.getZoom()),
});
我认为中心应该只是地图的中心,但问题是半径。我试图只插入一些值,但永远无法匹配。
【问题讨论】:
标签: javascript typescript google-maps google-maps-api-3