簡體   English   中英

反應地圖不渲染

[英]React map not rendering

我無法在屏幕上顯示我的Google地圖。 我已經看到了這個問題,但是即使這樣做也沒有解決我的問題。

我有的:

import React from 'react'
import GoogleMap from 'google-map-react';
import withStyles from 'isomorphic-style-loader/lib/withStyles'
import s from './CarMap.css'

class MoobieMap extends React.Component {

    constructor(props){
        super(props)
    }

    render() {
        return (
            <div className={s.map}>
            <GoogleMap apiKey={API_KEY} center={{lat: -23.5925282, long: -46.6891377}} zoom={3}/>
            </div>
        )
    }
}

export default withStyles(s)(MoobieMap)

和:

import React from 'react'
import Layout from '../../components/Layout'
import MoobieMap from './CarMap'

const title = 'Mapa de carros'

export default {

  path: '/car-map',

  async action() {
    return {
      title,
      chunk: 'component',
      component: <Layout title={title}><MoobieMap /></Layout>,
    }
  },

}

和CSS:

.map {
    width: 100%;
    height: 400px;
}

我也在使用React入門套件。 我的DOM看起來像這樣: 在此處輸入圖片說明

我的控制台中也沒有js錯誤。

我在這里想念什么? 謝謝!!!

編輯: 在此處輸入圖片說明

嘗試僅導入將它們命名為的css wihtout:

import React from 'react'
import GoogleMap from 'google-map-react';
import withStyles from 'isomorphic-style-loader/lib/withStyles'
import './CarMap.css'

class MoobieMap extends React.Component {

    constructor(props){
        super(props)
    }

    render() {
        return (
            <div>
            <GoogleMap apiKey={API_KEY} center={{lat: -23.5925282, long: -46.6891377}} zoom={3} className="map"/>
            </div>
        )
    }
}

export default withStyles(s)(MoobieMap)

MoobieMap和withstyles之間的連接是什么?

希望對您.map幫助,請告訴我您的.map聲明了寬度和高度...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM