我非常难以接受我编写的一些JavaScript/jQuery代码,这些代码在Webkit浏览器(Chrome和Safari)中完美工作,但在Firefox或IE中根本无法工作,我希望有人能指出我的错误?jQuery在Chrome和Safari中工作,但不是Firefox或IE?
我正在做的是用jQuery拉动GeoRSS feed,然后使用Leaflet在地图上绘制位置点。不知何故,当使用Firefox或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++;
});
});
});
谢谢!
Works on firefox 24 - mac –
“LatLng对象无效”? – adeneo
“mapbox.js中的”错误:无效的LatLng对象:(,)“。作为一个猜测,我会说在对象文字中的最后一个属性之后有一个尾随逗号。 –