[英]Is there any way to put a image inside a marker on the google maps?
I am using react-google-maps and want to use user's image inside marker. 我正在使用react-google-maps并希望在标记内使用用户的图像。 How can i put dynamic image inside a marker? 如何将动态图像放入标记内?
I tried using icon object of marker but it did not work because it just put a image on the map not inside a marker. 我尝试使用标记的图标对象,但它不起作用,因为它只是将图像放在地图上而不是标记内。
You can pass Options props in Marker component and put your image src url in icon property. 您可以在Marker组件中传递Options props,并将您的图像src url放在icon属性中。 (Not tested but I think it will work for you) (未经测试,但我认为它适合您)
Example 例
<GoogleMap
defaultZoom={8}
defaultCenter={{ lat: -34.397, lng: 150.644 }}
>
<Marker
options={{ icon: { url: ...., scaledSize: ...., size: .... } }}
position={{ lat: -34.397, lng: 150.644 }}
/>
</GoogleMap>
scaledSize : The size of the entire image after scaling, if any. scaledSize:缩放后整个图像的大小(如果有)。 Use this property to stretch/shrink an image or a sprite. 使用此属性可拉伸/缩小图像或精灵。
size : The display size of the sprite or image. size:精灵或图像的显示大小。 When using sprites, you must specify the sprite size. 使用精灵时,必须指定精灵大小。 If the size is not provided, it will be set when the image loads. 如果未提供尺寸,则将在图像加载时设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.