我一直在這個很長一段時間現在,我開始思考也許反應原生地圖不能在Android模擬器上工作,因爲所有的答案,我覺得似乎無論如何,工作都是爲了IOS。反應原生地圖不加載爲Android(空白地圖)
我目前使用android模擬器來運行我的應用程序。這裏是一個簡單的地圖的代碼...
class MainMap extends Component {
constructor() {
super();
}
render(){
return (
<View style={styles.container}>
<MapView
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
position: 'absolute',
top: 0,
width:150,
height:150,
left: 0,
right: 0,
bottom: 0,
},
});
module.exports = MainMap;
該代碼似乎應該工作,因爲我直接從一個例子。我甚至得到了來自谷歌API我的API密鑰,然後添加在我AndroidManifest.xml
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="api here"/>
現在,當我運行react-native run-android
應用程序看上去一切正常,沒有錯誤信息如下。但是,該應用程序是空白的。 View
容器加載正常,但其內容MapView
完全不加載。我所看到的只是一個空白的屏幕。
請注意,我的模擬器上也安裝了Google Play服務和Google API。
如何調試此問題,因爲我根本沒有收到任何錯誤消息?即使react-native maps
工作在Android模擬器上?
編輯
我一直停留在這個很長一段時間了,它的拖延我從能在這個項目上我的工作。由於問題的性質是難以調試,我要提供的情況下,任何人GitHub的鏈接到我的倉庫是願意複製他們的問題到底,看看我的問題是什麼...
https://github.com/Bolboa/TTC-Mapping
我只需要加載地圖。該代碼看起來像它應該工作,但地圖不會加載...
我會給任何人誰可以幫助我一個賞金。
嘗試'container' style with'container:{flex:1,justifyContent:'flex-end', alignItems:'center',}。 –
@ubatin我試過這個。看起來地圖根本就沒有加載... – Bolboa
你是否嘗試在google api控制檯上刪除api密鑰的簽名?我的意思是包名和SHA1密鑰。它是調試密鑰和釋放密鑰的問題。我只是問你是否考慮過這種方法? –