我有一个楼层地图图像,并且有大头针标记图标,并使用x,y坐标设置了大头针图标的位置,但是问题是大头针的(x,y)相对于窗口而不是图片的
如何设置图标相对于图像的位置?
import React, { Component } from "react";
import { View, Dimensions } from "react-native";
import Image from "react-native-scalable-image";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
childX: "360",
childY: "180"
};
}
render() {
return (
<Image
width={Dimensions.get("window").width}
source={require("./bg2.jpg")}
background={true}
>
<Image
style={{
transform: [
{ translateX: parseFloat(this.state.childX) },
{ translateY: parseFloat(this.state.childY) }
]
}}
source={{
uri:
"http://www.myiconfinder.com/uploads/iconsets/24-24-7a195b78d9607a48fb234f98634fa5ea-pin.png"
}}
/>
</Image>
);
}
}