Uncaught InvalidValueError: setMap: not an instance of Map

前端 未结 7 1177
萌比男神i
萌比男神i 2021-02-19 12:23

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

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


        
7条回答
  •  南旧
    南旧 (楼主)
    2021-02-19 13:08

    You can add the marker to the map directly by using the marker's setMap() method, as shown in the example below:

    var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
    var mapOptions = {
      zoom: 4,
      center: myLatlng
    }
    var map = new google.maps.Map(document.getElementById("map"), mapOptions);
    
    var marker = new google.maps.Marker({
        position: myLatlng,
        title:"Hello World!"
    });
    
    // To add the marker to the map, call setMap();
    marker.setMap(map);
    

提交回复
热议问题