'Uncaught InvalidValueError' (: setCenter: not a LatLng or LatLngLiteral object)

后端 未结 3 1575
一生所求
一生所求 2021-02-05 23:10

I\'m starting to know PHP and JavaScript, mixing them in HTML and using Google Maps API (version 3).

I figured how to \'put\' various markers but the console will throw

3条回答
  •  感情败类
    2021-02-05 23:17

    You are initializing mapOptions in wrong way.

    Initialize it in following way..

    var mapOptions = {
              center: new google.maps.LatLng(20.68177501, -103.3514794),
              zoom: 15,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            };
    

    Instead of...

    var mapOptions = {
              center: (20.68177501, -103.3514794), //this is not correct
              zoom: 15,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            };
    

    Following is corrected code...

    
    
      
        
            
    
            
    
    
          
    
    
      
      
        

提交回复
热议问题