简体   繁体   English

如何在@react-google-maps/api 中添加自定义 ico 或 SVG 作为标记图标

[英]How to add custom ico or SVG as marker icon in @react-google-maps/api

I am using @react-google-maps/api to show Google Map in my React Web application.我正在使用@react-google-maps/api在我的 React Web 应用程序中显示 Google Map。 Following their documentation I have added the marker as follows.根据他们的文档,我添加了如下标记。

 <Marker onLoad={onLoad} position={location} icon={{ // path: google.maps.SymbolPath.CIRCLE, url:'./../../assets/svg/location_marker.svg', scale: 7, }} />

But it seems to be not working.但它似乎不起作用。 There are no markers displayed.没有显示任何标记。 using google.maps.SymbolPath.CIRCLE as path will show the marker icon.使用google.maps.SymbolPath.CIRCLE作为path将显示标记图标。 Did anyone face this issue before?以前有人遇到过这个问题吗? any ideas?有任何想法吗?

Added require and solved the issue.添加了要求并解决了问题。

    <Marker
        onLoad={onLoad}
        position={deliveryDestination}
        icon={{
            // path: google.maps.SymbolPath.CIRCLE,
            url: (require('./../../assets/svg/location_marker.ico')),
            fillColor: '#EB00FF',
            scale: 7,
        }}
    />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM