React Native Maps: Markers image doesn't show using Custom Marker in react-native-maps

后端 未结 10 1839
别那么骄傲
别那么骄傲 2021-02-05 16:52

I\'m using react-native-maps but I faced a problem that after a lot of googling without answer makes me ask it here. I\'m trying to use Custom Marker for the marker

10条回答
  •  悲&欢浪女
    2021-02-05 17:13

    My problem was solved right now.

    I hope your problem will be solved.

    This is my clean code:

    import React, {Component} from 'react';
    import {ImageBackground, Text} from 'react-native';
    import {Marker} from 'react-native-maps';
    
    export default class CustomMarker extends Component {
        state = {
            initialRender: true
        }
    
        render() {
            return (
                
                    
    
                        // *** These lines are very important ***
                        onLoad={() => this.forceUpdate()}
                        onLayout={() => this.setState({initialRender: false})}
                        key={`${this.state.initialRender}`}
                        >
                        
    
                        // **** This line is very very important ****
                        {Math.random()}
    
                    
                
            );
        }
    }
    

提交回复
热议问题