Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes when add images on map as Marker #191

Open
UmarFarooqCA opened this issue Jun 23, 2022 · 0 comments
Open

App crashes when add images on map as Marker #191

UmarFarooqCA opened this issue Jun 23, 2022 · 0 comments

Comments

@UmarFarooqCA
Copy link

The app works fine when I remove the images from the map.

Android emulator and setup according to requirement. https://reactnative.dev/docs/environment-setup#development-os

  • Windows 11
  • React Native 0.67.3
  • react-native-maps 0.31.1
  • react-native-maps-directions 1.8.0

<View style={{ flex: 1 }}>
        <MapView
          initialRegion={{
            latitude: LATITUDE,
            longitude: LONGITUDE,
            latitudeDelta: LATITUDE_DELTA,
            longitudeDelta: LONGITUDE_DELTA,
          }}
          initialCamera={{
            altitude: 15000,
            center: {
              latitude: 23.7603,
              longitude: 90.4125,
            },
            heading: 0,
            pitch: 0,
            zoom: 11,
          }}
          provider={PROVIDER_GOOGLE}
          loadingEnabled
          loadingBackgroundColor="white"
          style={StyleSheet.absoluteFill}
          ref={c => (this.mapView = c)} // eslint-disable-line react/jsx-no-bind
          onPress={this.onMapPress}>
          <MapViewDirections
            origin={this.state.coordinates[0]}
            destination={
              this.state.coordinates[this.state.coordinates.length - 1]
            }
            waypoints={this.state.coordinates.slice(1, -1)}
            mode="DRIVING"
            apikey={API_KEY}
            language="en"
            strokeWidth={5}
            strokeColor="#007AFF"
            onStart={params => {
              console.log(
                `Started routing between "${params.origin}" and "${params.destination
                }"${params.waypoints.length
                  ? ' using waypoints: ' + params.waypoints.join(', ')
                  : ''
                }`,
              );
            }}
            onReady={this.onReady}
            onError={errorMessage => {
              console.log(errorMessage);
            }}
            resetOnChange={false}
          />
          <Marker
            anchor={{ x: 0.5, y: 0.6 }}
            coordinate={{
              latitude: coords[0].latitude,
              longitude: coords[0].longitude,
            }}
            flat
            style={{
              ...(coords[0].heading !== -1 && {
                transform: [
                  {
                    rotate: `${coords[0].heading}deg`,
                  },
                ],
              }),
            }}>
            <View>
              <View style={styles.card}>
                <Image source={img} />
                <View
                  style={{
                    paddingLeft: 10,
                  }}>
                  <Text style={{ color: '#383732' }}>Your Location</Text>
                  <Text
                    style={{
                      color: '#999894',
                      fontSize: 10,
                      lineHeight: 20,
                    }}>
                    123 Star St, New Y...
                  </Text>
                </View>
              </View>
              <View style={styles.dotContainer}>
                <View style={styles.dot} />
              </View>
            </View>
          </Marker>
          <Circle
            center={{
              latitude: coords[0]?.latitude,
              longitude: coords[0]?.longitude,
            }}
            radius={coords[0]?.accuracy}
            strokeColor="rgba(0, 150, 255, 0.5)"
            fillColor="rgba(0, 150, 255, 0.5)"
          />
          <Marker
            anchor={{ x: 0.5, y: 0.6 }}
            coordinate={{
              latitude: coords[1].latitude,
              longitude: coords[1].longitude,
            }}
            flat
            style={{
              ...(coords[1].heading !== -1 && {
                transform: [
                  {
                    rotate: `${coords[1].heading}deg`,
                  },
                ],
              }),
            }}>
            <View>
              <View style={styles.card}>
                <Image source={img2} />
                <View
                  style={{
                    paddingLeft: 10,
                  }}>
                  <Text style={{ color: '#383732' }}>Your Location</Text>
                  <Text
                    style={{
                      color: '#999894',
                      fontSize: 10,
                      lineHeight: 20,
                    }}>
                    123 Star St, New Y...
                  </Text>
                </View>
              </View>

              <View style={styles.dotContainer}>
                <View style={styles.dot} />
              </View>
            </View>
          </Marker>
          <Circle
            center={{
              latitude: coords[1]?.latitude,
              longitude: coords[1]?.longitude,
            }}
            radius={coords[1]?.accuracy}
            strokeColor="rgba(0, 150, 255, 0.5)"
            fillColor="rgba(0, 150, 255, 0.5)"
          />
        </MapView>
      </View>

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant