Uncaught InvalidValueError: setMap: not an instanc

2019-04-04 14:04发布

when i used the sencha touch2.2.1,i met a question. In the viewer:

items: [{
    id: 'mapCanvas',
    xtype:'map',
    useCurrentLocation: true,
}]

In the controller:

var map= Ext.getCmp('mapCanvas');
console.dir(map);
var marker= new google.maps.Marker({
                position: new google.maps.LatLng(25,118),
            });
marker.setMap(map);

report the error:

Uncaught InvalidValueError: setMap: not an instance of Map, and not an instance of StreetViewPanorama

I can see the map,but i can't see the marker, and how to solve the problem?

7条回答
你好瞎i
2楼-- · 2019-04-04 15:09

var map is a HTML element you need an instance of the google.maps.Map Object

var map = google.maps.Map(document.querySelector("#mapCanvas"),{
      center: new google.maps.LatLng(24.027872, -104.655278),
      zoom: 12
    });

then....

var marker= new google.maps.Marker({
  position: new google.maps.LatLng(25,118),
  map: map
    });
查看更多
登录 后发表回答