Android n我的标记自定义视图,因为我需要使用带有iamge长边自定义视图的文本。这对我有效@abdu4非常感谢您的回答,但同样的结果是,地图加载但图像未显示。还有其他想法吗@Mahdi Bashirpour因为我自己也有同样的问题,我现在正在努力解决。我在@abd

Android n我的标记自定义视图,因为我需要使用带有iamge长边自定义视图的文本。这对我有效@abdu4非常感谢您的回答,但同样的结果是,地图加载但图像未显示。还有其他想法吗@Mahdi Bashirpour因为我自己也有同样的问题,我现在正在努力解决。我在@abd,android,google-maps,react-native,react-native-maps,Android,Google Maps,React Native,React Native Maps,n我的标记自定义视图,因为我需要使用带有iamge长边自定义视图的文本。这对我有效@abdu4非常感谢您的回答,但同样的结果是,地图加载但图像未显示。还有其他想法吗@Mahdi Bashirpour因为我自己也有同样的问题,我现在正在努力解决。我在@abdu4I上得到了很好的结果,我认为您必须为ImageBackgrund添加样式,至少在android上运行会显示这个错误@Mahdi BashirpourInstead不再使用原生基,而是测试这个简单的my代码。也许这是个问题。或者在地图以外的其


n我的标记自定义视图,因为我需要使用带有iamge长边自定义视图的文本。这对我有效@abdu4非常感谢您的回答,但同样的结果是,地图加载但图像未显示。还有其他想法吗@Mahdi Bashirpour因为我自己也有同样的问题,我现在正在努力解决。我在@abdu4I上得到了很好的结果,我认为您必须为ImageBackgrund添加样式,至少在android上运行会显示这个错误@Mahdi BashirpourInstead不再使用
原生基
,而是测试这个简单的my代码。也许这是个问题。或者在地图以外的其他地方测试组件代码,看看它是否在那里工作@abdu4如果整个事情都是在地图上工作的,那么很可能带有组件
native base
的地图有问题@abdu4对不起,这不是问题,我想问题出在Android上。@Mahdi BashirpourSo完全使用我的代码。请放心,这将是真的,因为我已经尝试过@Abdu4can u也请添加一个示例?这不是关于编码,而是关于替换图像。您的图像应为8位gamma整数格式。
import React, { Component } from "react";
import { View } from "react-native";
import {
Text,
Left,
Right,
Thumbnail,
} from "native-base";
const defaultEmployeeLogo = require("../../../assets/defualtEmployee.png");
class CustomMarker extends Component {
render() {
    return (
    <View style={{ flexDirection: 'row', width: 140, height: 60, 
      borderRadius: 70, backgroundColor: 'orange' }}>
        <Left>
            <Thumbnail source={defaultEmployeeLogo} />
        </Left>
        <Right>
            <Text style={{
                color: '#fef',
                fontSize: 13,
                paddingBottom: 2,
                fontFamily: 'Roboto',
                alignItems: 'center',
                paddingRight: 10
            }}>Mohammad</Text>
        </Right></View >);
   }
}
export default CustomMarker;
return (
  <View style={styles.map_container}>
    <MapView
      style={styles.map}
      customMapStyle={customrMapStyle}
      region={{
        latitude: this.state.region.latitude,
        longitude: this.state.region.longitude,
        latitudeDelta: 0.4,
        longitudeDelta: 0.41,
      }} >
      {
        coordinationData.map(function (marker, i) {

          let lat = marker.latLang.latitude;
          let lang = marker.latLang.longitude;
           <MapView.Marker
            key={i}
            coordinate={
              {
                latitude: lat,
                longitude: lang,
                latitudeDelta: 0.4,
                longitudeDelta: 0.41
              }
            }
            title={marker.title}
            description={marker.description}

          >
            <CustomMarker />
          </MapView.Marker>
        })}
    </MapView>
  </View>
const defaultEmployeeLogo = require("../../../assets/defualtEmployee.png");

<Image source={defaultEmployeeLogo} onLoad={() => this.forceUpdate()}>
    <Text style={{width:0, height:0}}>{Math.random()}</Text>
</Image>
class PinMarker extends Component {
  state = {
    initialRender: true
  }
  render() {
    return (
      <MapView.Marker coordinate={coordinate}>
        <Image
          source={...}
          onLayout={() => this.setState({ initialRender: false })}
          key={`${this.state.initialRender}`}
        />
      </MapView.Marker>
    )
  }
}
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 (
            <Marker
              //...
            >
                <ImageBackground
                    source={require('../assets/cluster3_mobile.png')}>

                    // *** These lines are very important ***
                    onLoad={() => this.forceUpdate()}
                    onLayout={() => this.setState({initialRender: false})}
                    key={`${this.state.initialRender}`}
                    >
                    

                    // **** This line is very very important ****
                    <Text style={{width: 0, height: 0}}>{Math.random()}</Text>

                </ImageBackground>
            </Marker>
        );
    }
}
<MapView.Marker>
    <Image source={img_marker} />
</MapView.Marker>
class Map extends React.Component {
render() {
    let {region, markers , markerClick} = this.props;
    const normalMarkerImage = require('../../images/normal_marker.png');
    const selectedMarkerImage = require('../../images/selected_marker.png');
    return !isObjectEmpty(region) && !isObjectEmpty(markers) ? (
        <MapView
            style={styles.map}
            showsUserLocation={true}
            followUserLocation={true}
            zoomEnabled={true}
            region={region}
            paddingAdjustmentBehavior={'automatic'}
            showsIndoors={true}
            showsIndoorLevelPicker={false}
            showsTraffic={false}
            toolbarEnabled={false}
            loadingEnabled={true}
            showsMyLocationButton={true}>
            {markers && markers.length > 0
                ? markers.map((marker, i) => (
                        <MapView.Marker
                            coordinate={{
                                longitude: marker.loc.coordinates[0],
                                latitude: marker.loc.coordinates[1],
                            }}
                            key={`marker-${i}`}
                            style={{height: 20, width: 20}}
                            onPress={e => markerClick(e, marker)}
                            image={
                                this.props.selectedMarker === marker._id
                                    ? selectedMarkerImage
                                    : normalMarkerImage
                            }
                        />
                  ))
                : null}
        </MapView>
    ) : null;
  }
}
markerClick = async (event, data) => {
    this.props.dispatch(
        setMarkerIconInRedux(this.state.popover.currentData._id)
    );
};
<Marker
    coordinate={{
        longitude: lang,
        latitude: lat,
    }}
>
    <View style={{
        flexDirection: 'row', width: 100, height: 30,
        backgroundColor: 'orange'
    }}>
        <Svg
            width={40} height={30}>
            <Image
                href={url}
                width={40}
                height={30}
            />
        </Svg>
        <View
            style={{
                flexDirection: 'column'

            }}
        >
            <Text
                style={{
                    marginLeft: 2,
                    fontSize: 9,
                    color: '#ffffff',
                    fontWeight: 'bold',
                    textDecorationLine: 'underline'
                }}
            >{marker.title}</Text>
            <Text
                style={{
                    marginLeft: 2,
                    fontSize: 9,
                    color: '#ffffff',
                    fontWeight: 'bold',
                    textDecorationLine: 'underline'
                }}
            >{marker.description}</Text>
        </View>
    </View>
</Marker>
import {Image} from 'react-native';   // for other images in our render method.
import { Image as Imagesvg } from 'react-native-svg';

<Marker
   coordinate={marker.latlng}
   title={marker.title}
 >

<View style={{ height: 90, width: 90, backgroundColor: 'orange' }}>
      <Svg width={90} height={90}}>
        <Imagesvg href={marker_g} width={90} height={90} />  // Local Images
       <Imagesvg href={{uri:url}} width={90} height={90} />   //Server images
    </Svg>
</View>
</Marker>
export const UserMapPin = props => {
  const [trackView, setTrackView] = useState(true);

  function changeTrackView() {
    setTrackView(false);
  }

  return (
    <Marker
      tracksViewChanges={trackView}
      coordinate={props.coordinates}>
      <View style={styles.imageIconContainer}>
          <FastImage
            onLoadEnd={changeTrackView}
            style={styles.someImageStyle}
            source={{
              uri: props.imageURI,
            }}
            resizeMode={FastImage.resizeMode.cover}
          />
      </View>
    </Marker>
  );
};
    <Image
     source={{ uri: "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg" }}
     style={styles.companyLogoMarker}
     resizeMode="cover"
     />
     <Text style={styles.markerText}>
        {names?.[0]?.value}
       <Image
           source={{ uri: "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg" }}
           style={{width: 0, height: 0}}
           resizeMode="cover"
        />
     </Text>