2016-11-06 4 views
0

私はコンソールに乗り続けているエラーを理解してデバッグしようとしています。私は流星プロジェクトでGoogleマップを実装しています。私はTypeError: Cannot create property 'mapTypeId' on stringエラーat Object.create google-mapsこれを見続けるどのように私は上の私のマップを作成していますに関連するエラーをdburles:google-mapsパッケージTypeError:文字列 'Mapを読み込めません'のプロパティ 'mapTypeId'を作成できません。流星のエラー

create: function(options) { 
    // default to Map 
    var type = options.type ? options.type : 'Map'; 
    if (! _.include(supportedTypes, type)) { 
     throw new Meteor.Error("GoogleMaps - Invalid type argument: " + type); 
    } 

    this._create(options.name, { 
     type: type, 
     instance: new google.maps[type](options.element, options.options), //<= [ERROR] here 
     options: options.options 
    }); 

からのコードの問題のある行をdburles:google-maps & mdg:geolocation

をされている使用しています私のテンプレート?私は地図を見ることができます、私はちょうどエラーを理解したいと思います。

マイコード:

map.tpl.jade

section.section--map 
    .section--map__bgImage 
    .section--map__content 
     h1.section--map__title Frit.kots available right now 
     .section--map__container 
      unless geolocationError 
       +googleMap(type='Map' name='map' options=mapOptions) 
      else 
       | Geolocation failed: {{geolocationError}} 
+footer 

map.js

import './map.tpl.jade'; 


// [FIX-ME]: This part of the code must be fixed 

Meteor.startup(() => { 
    GoogleMaps.load({ 
     v: '3', 
     key: 'MY_API_KEY' 
     // libraries: 'places' 
    }); 
}) 


// onCreated 
Template.map.onCreated(function() { 

    let self = this; 
    let MAP_ZOOM = 15; 
    let loadedMap = GoogleMaps.loaded(); 

    console.log('Creating the map'); 
    console.log(`These are the map vars: ${MAP_ZOOM} && ${loadedMap}`); 

    GoogleMaps.ready('map', (map) => { 

     let marker; 

     // Create and move marker when latLng changes 
     self.autorun(() => { 
      let latLng = Geolocation.latLng; 

      if (!latLng) { 
       return; 
      } 

      // if marker doesn't exist, create one 
      if (! marker) { 
       marker = new google.maps.Marker({ 
        // position: new google.maps.LatLng(latLng.lat, latLng.lng), 
        position: map.options.center, 
        map: map.instance 
       }); 
      // if marker already exists, change its position 
      } else { 
       marker.setPosition(latLng); 
      } 
      // Center and zoom the map view into 
      map.instance.setCenter(marker.getPosition()); 
      map.instance.setZoom(MAP_ZOOM); 
     }) 
    }) 
}); 


// Helpers 
Template.map.helpers({ 
    geolocationError:() => { 

     let error = Geolocation.error(); 
     console.log(`This is the error message: ${error}.message`); 
     return error && error.message; 
    }, 
    mapOptions:() => { 
     let latLng = Geolocation.latLng(); 
     let loadedMap = GoogleMaps.loaded(); 
     let MAP_ZOOM = 15; 

     // Initialize the map once 
     if (loadedMap && latLng) { 
      return { 
       center: new google.maps.LatLng(latLng.lat, latLng.lng), 
       zoom: MAP_ZOOM 
      } 
     } else { 
      return 'Unable to load the map'; 
     } 
    } 
}); 

答えて

0
instance: new google.maps[type](options.element, options.options) 

私は、データ構造にエラーがあると仮定します。 google.mapsのドキュメントをもう一度チェックして、通話権を構築していることを確認してください。また、正しいタイプの正しい引数であることを確認してください。

関連する問題