我在试图旋转标记在反应传单上有困难。
我已经看到了一些例子,它是用一个较旧版本的反应传单使用传单旋转标记。见下文..。已经尝试使用这两个示例而没有任何结果,也尝试过用transform: rotate(18deg);覆盖css,但这也不起作用。如有任何帮助,将不胜感激。
package.json:
"dependencies": {
...
"@types/leaflet": "^1.9.0",
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"leaflet": "^1.9.2",
"leaflet-rotatedmarker": "^0.2.0",,
"react-leaflet": "^4.1.0",
"react-scripts": "5.0.1",
"typescript": "^4.4.2"
},结果:
import 'leaflet-rotatedmarker';
import L, { LatLngBoundsLiteral, LatLngBounds, Icon, LatLng, map } from "leaflet";
...
let m = L.marker([51.505, -0.09]).addTo(map);
m.setRotationAngle(180);


发布于 2022-11-11 11:01:40
添加传单旋转标记:npm源
如果您使用的是打字本,请使用:
yarn add @types/leaflet-rotatedmarker
import { MapContainer, Marker, TileLayer, Tooltip } from "react-leaflet";
import 'leaflet-rotatedmarker';
....
//add rotationAngle
<Marker
icon={myIcon}
key={data.key}
position={[data.latitude, data.longitude]}
rotationAngle={data.angle}
>
</Marker>https://stackoverflow.com/questions/74368250
复制相似问题