react-native-mapbox-gl icon indicating copy to clipboard operation
react-native-mapbox-gl copied to clipboard

Symbol layer(iconImage (styling )) is not able to load remote images through a url.

Open aurimusblack opened this issue 7 years ago • 10 comments

Symbol layer(iconImage style) is not able to load remote images through a url.

TypeError: expected dynamic type 'string', but had type 'object'. screenshot_2018-06-08-13-13-46-413_com snapmap

aurimusblack avatar Jun 08 '18 07:06 aurimusblack

can you show me how you are setting your image?

nitaliano avatar Jun 08 '18 16:06 nitaliano

@nitaliano

const markerStyles = MapboxGL.StyleSheet.create({
  icon:{
    iconImage : {uri: "url here"},
    iconSize: 0.7
  }
})

<Marker id={marker} iconId={icon} onPress={this.onPress} style={markerStyles.icon} shape={this.state.featureCollection[j]}/>

marker is a custom component that I created:
class Marker extends Component<{}> {
  constructor(props) {
    super(props);
    this.onPressWrapper = this.onPressWrapper.bind(this)
  }
  onPressWrapper(){
    this.props.onPress(this._smap.props.shape.features[0].geometry.coordinates);
  }

  render(){
    return(
      <MapboxGL.ShapeSource
        id={this.props.id}
        shape={this.props.shape}
        cluster={true}
        onPress={this.onPressWrapper}
        ref={(ref) => (this._smap = ref)}
        clusterRadius={100}
        >
          <MapboxGL.SymbolLayer id={this.props.iconId} style={this.props.style}/>
      </MapboxGL.ShapeSource>
    );
  }
}

aurimusblack avatar Jun 09 '18 06:06 aurimusblack

@nitaliano

I am also facing the same issue .Can you please help me out

vamsiraju1 avatar Jun 13 '18 11:06 vamsiraju1

I'm facing the same issue. Please help me.

rajkamal3 avatar Jun 16 '18 06:06 rajkamal3

@nitaliano can you help on this? Thanks !!

DipanshKhandelwal avatar Jul 13 '18 21:07 DipanshKhandelwal

I had the same problem and fixed it placing the url in the images object Example:

const markerStyles = MapboxGL.StyleSheet.create({
  icon:{
    iconImage : 'myImage',
    ...
  }
})

class Marker extends Component<{}> {
  ...
  render(){
    return(
      <MapboxGL.ShapeSource
        id={this.props.id}
        shape={this.props.shape}
        images={myImage: {uri: "url here"}}
        ...
        >
          <MapboxGL.SymbolLayer id={this.props.iconId} style={this.props.style}/>
      </MapboxGL.ShapeSource>
    );
  }
}

slaivyn avatar Jan 08 '19 17:01 slaivyn

Excuse me! how to set the base64 image

wywzixin avatar Jan 09 '19 07:01 wywzixin

I had the same problem and fixed it placing the url in the images object Example:

const markerStyles = MapboxGL.StyleSheet.create({
  icon:{
    iconImage : 'myImage',
    ...
  }
})

class Marker extends Component<{}> {
  ...
  render(){
    return(
      <MapboxGL.ShapeSource
        id={this.props.id}
        shape={this.props.shape}
        images={myImage: {uri: "url here"}}
        ...
        >
          <MapboxGL.SymbolLayer id={this.props.iconId} style={this.props.style}/>
      </MapboxGL.ShapeSource>
    );
  }
}

Excuse me! how to set the base64 image

wywzixin avatar Jan 09 '19 07:01 wywzixin

@gisert Have you got any solution?

Madhavan-reactiveworks avatar Apr 10 '19 10:04 Madhavan-reactiveworks

how can implement dynamic image , like map on array for markers ?

array.map((item) = > {
  return <Marker image={item.icon} ... />
 }

mojtabadarzi avatar May 05 '21 08:05 mojtabadarzi