Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用谷歌地图时出现奇怪的jquery原型问题_Javascript_Jquery_Google Maps_Google Maps Api 3_Prototypejs - Fatal编程技术网

Javascript 使用谷歌地图时出现奇怪的jquery原型问题

Javascript 使用谷歌地图时出现奇怪的jquery原型问题,javascript,jquery,google-maps,google-maps-api-3,prototypejs,Javascript,Jquery,Google Maps,Google Maps Api 3,Prototypejs,我有一个cakePhp网站,我使用原型制作所有ajax内容,使用jQuery制作动画 我处理jquery原型问题的方式如下: echo $javascript->link('jquery-1.6.2'); echo $javascript->link('jquery.cookie'); echo $javascript->link('jQueryNoConflict'); echo $javascript->link('prototype'); function I

我有一个cakePhp网站,我使用原型制作所有ajax内容,使用jQuery制作动画

我处理jquery原型问题的方式如下:

echo $javascript->link('jquery-1.6.2');
echo $javascript->link('jquery.cookie');
echo $javascript->link('jQueryNoConflict');
echo $javascript->link('prototype');
  function InitMap(elementId, initPosition, initZoom, multiplePolygonsString) {
   var pos = initPosition.split(',');
    var myLatLng = new google.maps.LatLng(pos[0], pos[1]    );
    var myOptions = {
      zoom:initZoom,
      center: myLatLng,
      mapTypeId: google.maps.MapTypeId.TERRAIN
    };

    map = new google.maps.Map(document.getElementById(elementId),       myOptions);
    var multiplePolygons = multiplePolygonsString.split(';');
    for(var i=0;i<multiplePolygons.length;i++){
        var currentPolygon,match,coordinates = [];

        var reg = /\(\s*([0-9.-]+)\s*,\s*([0-9.-]+)\s*\)/g ;

        while((match =  reg.exec(multiplePolygons[i]))!==null){
            coordinates.push(   new google.maps.LatLng(+match[1], +match[2]));  
        }

        currentPolygon = new google.maps.Polygon({
            paths: coordinates,
            strokeColor: "#FF0000",
            strokeOpacity: 0.8,
            strokeWeight: 3,
            fillColor: "#FF0000",
            fillOpacity: 0.35
        });

        currentPolygon.setMap(map);

        // Add a listener for the click event
        google.maps.event.addListener(currentPolygon, 'click', function(event){         showArrays(event, "testInfoBulle");     });
    }



    infowindow = new google.maps.InfoWindow();
  }
而jQuerynoConflict只包含

$.noConflict();
我已经完成了一个小JS脚本,它使用定义的类显示项目,并使用另一个类隐藏其他项目:

if(jQuery.cookie('isRawPrice')==1){ 
    jQuery('.priceWithoutTva').show();
    jQuery('.priceWithTva').hide(); 
}else{

    jQuery('.priceWithoutTva').hide();
    jQuery('.priceWithTva').show(); 
}
这在我的每一页上都有效,除了我有谷歌地图项目的那一页。我这样补充:

echo $javascript->link('jquery-1.6.2');
echo $javascript->link('jquery.cookie');
echo $javascript->link('jQueryNoConflict');
echo $javascript->link('prototype');
  function InitMap(elementId, initPosition, initZoom, multiplePolygonsString) {
   var pos = initPosition.split(',');
    var myLatLng = new google.maps.LatLng(pos[0], pos[1]    );
    var myOptions = {
      zoom:initZoom,
      center: myLatLng,
      mapTypeId: google.maps.MapTypeId.TERRAIN
    };

    map = new google.maps.Map(document.getElementById(elementId),       myOptions);
    var multiplePolygons = multiplePolygonsString.split(';');
    for(var i=0;i<multiplePolygons.length;i++){
        var currentPolygon,match,coordinates = [];

        var reg = /\(\s*([0-9.-]+)\s*,\s*([0-9.-]+)\s*\)/g ;

        while((match =  reg.exec(multiplePolygons[i]))!==null){
            coordinates.push(   new google.maps.LatLng(+match[1], +match[2]));  
        }

        currentPolygon = new google.maps.Polygon({
            paths: coordinates,
            strokeColor: "#FF0000",
            strokeOpacity: 0.8,
            strokeWeight: 3,
            fillColor: "#FF0000",
            fillOpacity: 0.35
        });

        currentPolygon.setMap(map);

        // Add a listener for the click event
        google.maps.event.addListener(currentPolygon, 'click', function(event){         showArrays(event, "testInfoBulle");     });
    }



    infowindow = new google.maps.InfoWindow();
  }
这基本上是加载地图并在定义的区域上创建一些多边形。。每次我显示这张地图时,它都生成得很好

但当我显示它并尝试用前面的代码隐藏/显示时,我得到了以下异常:

Uncaught TypeError: Object #<SVGAnimatedString> has no method 'match'prototype.js:300
Enumerable.eachprototype.js:300
Enumerable.injectprototype.js:372
document.getElementsByClassNameprototype.js:932
Sizzlejquery-1.6.2.js:4869
jQuery.fn.extend.findjquery-1.6.2.js:5188
jQuery.fn.jQuery.initjquery-1.6.2.js:189
jQueryjquery-1.6.2.js:27
updateDisplay.js:26 ---> This is the jQuery('.priceWithoutTva').show(); line
(anonymous function)cat3:3000:643
onclickcat3:3000:644

当他使用jquery方法时,为什么它会通过原型库??

它可能与您的匹配变量冲突,或者与原型或jquery文件中的全局匹配变量或函数冲突?尝试将您的名称重命名为更独特的名称,看看会发生什么。

我使用的是jQuery 1.6.2和prototype 1.4,现在我更新为jQuery 1.6.4和prototype 1.7,它正在工作

我试过了,但没有变化我用myCustomMatch代替了我的匹配