react-native-maps icon indicating copy to clipboard operation
react-native-maps copied to clipboard

Blank map on iOS

Open tedjames opened this issue 9 years ago • 26 comments

First time using react-native-maps. I've tried react-native link and manually linking everything together. I've made sure that everything is linked when using react-native link, deleted my builds, rebuilt my project, and even tried using this on a completely new project running React Native 0.41.0 with React 15.4.0-rc.4 but no matter what I do, the component never renders.

I've tried using react-native-maps 0.13 and 0.12.4 but neither worked...

tedjames avatar Feb 05 '17 20:02 tedjames

Can you post your code? Nothing was rendering for me before I set an explicit width (height works fine)

arsanjea avatar Feb 05 '17 20:02 arsanjea

Just gave that a try but it didn't work...

import React, { Component } from 'react';
import {
  AppRegistry,
  View
} from 'react-native';
import MapView from 'react-native-maps';

export default class myApp extends Component {
  render() {
    return (
      <View style={{ width: 500 }}>
        <MapView
          initialRegion={{
            latitude: 37.78825,
            longitude: -122.4324,
            latitudeDelta: 0.0922,
            longitudeDelta: 0.0421,
          }}
        />
      </View>

    );
  }
}

AppRegistry.registerComponent('myApp', () => myApp);

tedjames avatar Feb 05 '17 20:02 tedjames

Just tried this with rn 0.39.2 and rn-maps 0.12.4. Same thing is happening :/

tedjames avatar Feb 05 '17 20:02 tedjames

Thanks actually! What you suggested worked. Just needed to switch over to using a stylesheet:

import React, { Component } from 'react';
import { Text, View, Dimensions, ScrollView, StyleSheet } from 'react-native';
import { GradientView } from '../../Common'
import MapView from 'react-native-maps';

const { width, height } = Dimensions.get('window');
const SCREEN_WIDTH = width;
const ASPECT_RATIO = width / height;
const LATITUDE = 37.78825;
const LONGITUDE = -122.4324;
const LATITUDE_DELTA = 0.0922;
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;

export default class Analysis extends Component {
  constructor(props) {
    super(props);

    this.state = {
      region: {
        latitude: LATITUDE,
        longitude: LONGITUDE,
        latitudeDelta: LATITUDE_DELTA,
        longitudeDelta: LONGITUDE_DELTA,
      },
    };
  }

  render() {
    return (
      <View style={styles.container}>
        <ScrollView
          style={StyleSheet.absoluteFill}
          contentContainerStyle={styles.scrollview}
        >
          <MapView
            provider={this.props.provider}
            style={styles.map}
            scrollEnabled={true}
            zoomEnabled={true}
            pitchEnabled={true}
            rotateEnabled={true}
            initialRegion={this.state.region}
          >
            <MapView.Marker
              title="This is a title"
              description="This is a description"
              coordinate={this.state.region}
            />
          </MapView>
        </ScrollView>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    justifyContent: 'flex-end',
    alignItems: 'center',
  },
  scrollview: {
    alignItems: 'center',
  },
  map: {
    width: SCREEN_WIDTH,
    height: 250,
  },
});

tedjames avatar Feb 05 '17 21:02 tedjames

Happy it's working for you. TBC - not sure what was not working first, but the following piece of code works fine. So using Stylesheet is NOT a requirement:

import React, { Component } from 'react';
import { View, AppRegistry } from 'react-native';
//import { GradientView } from '../../Common'
import MapView from 'react-native-maps';

export default class sandbox extends Component {
  render() {
    return (
      <View style={{ position: 'relative', height: 500}}>
        <MapView
          style={{ left:0, right: 0, top:0, bottom: 0, position: 'absolute' }}
          initialRegion={{
            latitude: 37.78825,
            longitude: -122.4324,
            latitudeDelta: 0.0922,
            longitudeDelta: 0.0421,
          }}
        />
      </View>

    );
  }
}

arsanjea avatar Feb 05 '17 22:02 arsanjea

Awesome, that code worked perfectly. Appreciate the help! 👍

tedjames avatar Feb 05 '17 22:02 tedjames

I had a similar issue when updating to react-native 0.40.0, I tried adding a stylesheet and explicitly setting the width but it didn't work:


        <MapView style={styles.map}
            initialRegion={{
            latitude: 37.78825,
            longitude: -100.4324,
            latitudeDelta: 150,
            longitudeDelta: 150,
          }}>
          {this.state.markers.map(marker => (
              <MapView.Marker 
                key={marker.id}
                coordinate={marker.latlng}
                title={marker.title}
                description={marker.description}
                pinColor={'#000000'}
              />
          ))}
         </MapView>  

Any ideas as to what might be happening?

nnarang7 avatar Feb 07 '17 02:02 nnarang7

Hi,

I have successfully implemented map on simulator. But while i am archiving the build i am getting following error -

Apple Mach-O Linker (ld) Error Group

ld: 396 duplicate symbols for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please help me

rajeshkos avatar Feb 07 '17 09:02 rajeshkos

@rajeshkos I'd suggest you make a new issue for that. If I had to guess, it sounds like an issue with the linking process. Initialize a new project and try linking everything manually without react-native link.

Use instructions here as a guide: https://github.com/airbnb/react-native-maps/issues/693#issuecomment-259804156

This may help too: https://gist.github.com/heron2014/e60fa003e9b117ce80d56bb1d5bfe9e0

tedjames avatar Feb 07 '17 15:02 tedjames

@rajeshkos i had the same issue , that's bc the new react native version links headers in different ways . Try to update your RN and React-Native Maps to the lastest version

seppemarotta avatar Feb 09 '17 04:02 seppemarotta

Hey @rajeshkos, I actually ran into that issue yesterday. It came up when I removed react-native-maps and tried adding it back. Ended up having to rebuild my project from scratch :/

tedjames avatar Feb 09 '17 07:02 tedjames

Hi @tedjames thanks for your reply.

I have created a new project from scratch but still unable to archive and facing same linker error.

I am able to run directly app on the device but no success while archiving. :(

rajeshkos avatar Feb 09 '17 11:02 rajeshkos

Hmm.. post a screenshot of the file that the errors are pointing towards. We should be able to find a reference to what's causing the issue.

tedjames avatar Feb 09 '17 22:02 tedjames

@arsanjea , CC: @airbnbelena , @bipinairbnb I tried your snippet and it shows the rectangle only, no map showed. screenshot at mar 21 16-48-57

Can you help me to fix this? Thanks.

ithieund avatar Mar 21 '17 09:03 ithieund

+1

leandrojo avatar Apr 10 '17 17:04 leandrojo

same. Only red border,no map shows. I use the option 3 to install and don't use google map support @ithieund have u fixed the bug yet,please? Thanks a lot

zengyanzi avatar May 05 '17 10:05 zengyanzi

@zengyanzi The red border means it has not installed correctly, or you have not yet rebuilt the apk with airbnb maps installed. React-native link might not work for maps, as it did not for me. I had to follow the instalation guide as if i had not run link.

Rubenvdabeele avatar May 06 '17 19:05 Rubenvdabeele

@Rubenvdabeele thanks a lot.I installed it from a brand new project and not it works fine. Thank you very much. I used the manually option 3..

zengyanzi avatar May 07 '17 21:05 zengyanzi

@zengyanzi , Yes I solved it. Just follow this instruction: https://gist.github.com/heron2014/e60fa003e9b117ce80d56bb1d5bfe9e0

Thanks.

ithieund avatar May 08 '17 05:05 ithieund

Running this and restarting the IOS Simulator fixed it for me. react-native link react-native-maps Read this: https://github.com/airbnb/react-native-maps/blob/master/docs/installation.md

cedricf avatar Jun 04 '17 15:06 cedricf