2013-10-18 2 views
1

필자는 Webkit 브라우저 (Chrome 및 Safari)에서 완벽하게 작동하는 일부 JavaScript/jQuery 코드에 난처하지만 Firefox 또는 IE에서 전혀 작동하지 않으며 누군가 내 오류를 지적 할 수 있기를 희망합니다.jQuery는 Chrome 및 Safari에서 작동하지만 Firefox 또는 IE에서 작동하지 않습니까?

내가하고있는 일은 jQuery로 GeoRSS 피드를 가져 와서 전단지를 사용하여지도에서 위치 지점을 플로팅하는 것입니다. 어쨌든 포인트는 파이어 폭스 또는 IE를 사용할 때 플롯되지 않습니다? http://bit.ly/19N0I75

을 그리고 여기에 코드입니다 : 여기에 해당 페이지의

var map = L.mapbox.map('map', 'primitive.geography-class').setView([42, 22], 4); 

var wordpressIcon = L.icon({ 
iconUrl: 'http://www.shifting-sands.com/wp-content/themes/shiftingsands/images/icons/wordpress.png', 

iconSize:  [18, 18], // size of the icon 
shadowSize: [0, 0], // size of the shadow 
iconAnchor: [9, 9], // point of the icon which will correspond to marker's location 
shadowAnchor: [0, 0], // the same for the shadow 
popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor 
}); 

jQuery(document).ready(function($){ 
$.get("http://shifting-sands.com/feed/", function (data) { 
var $xml = $(data); 
var $i = 0; 
$xml.find("item").each(function() { 
    var $this = $(this), 
     item = { 
      title: $this.find("title").text(), 
      linkurl: $this.find("link").text(), 
      description: $this.find("description").text(), 
      pubDate: $this.find("pubDate").text(), 
      latitude: $this.find("lat").text(), 
      longitude: $this.find("long").text() 
     } 

       lat = item.latitude; 
       long = item.longitude; 
       title = item.title; 
       clickurl = item.linkurl; 

       //Get the url for the image. 
       var htmlString = '<h4><a href="' + clickurl + '" target="_blank">' + title + '</a></h4>';      
       var contentString = '<div id="content">' + htmlString + '</div>'; 

       //Create a new marker position using the Leaflet API. 
       var rssmarker = L.marker([lat, long], {icon: wordpressIcon}).addTo(map); 

       //Create a new info window using the Google Maps API 

       rssmarker.bindPopup(contentString, {closeButton: true}); 


    $i++; 
}); 
}); 
}); 

감사합니다!

+0

Firefox에서 작동 24 - mac –

+0

"잘못된 LatLng 개체"? – adeneo

+0

"오류 : 잘못된 LatLng 개체 : (,)"가 mapbox.js에 있습니다. 짐작할 수 있듯이 객체 리터럴의 마지막 속성 다음에 쉼표가 있습니다. –

답변

0

lat 값이 네임 스페이스 (geo : lat)이므로 find()에서 아무런 가치가 없습니다. 따라서 오류 (,), 두 개의 빈 값은 쉼표로 구분됩니다. 쿼리를 다음과 같이 변경해야합니다.

latitude: $this.find("geo\\:lat").text() 

이중 백 슬래시가 콜론을 이스케이프합니다.

+0

도움 주셔서 감사합니다. 하지만 Chrome, Safari, Opera에서는 혼란 스럽습니다. 변경 사항이있는지도는 다음과 같습니다. http://bit.ly/19XLQEL – Tim

+0

해결되었습니다! jQuery의 버그는 위도 : $ this.find ("geo \\ : lat, lat")가되어야 함을 의미합니다. text()' 'longitude : $ this.find ("geo \\ : long, long "). text()' – Tim

관련 문제