से एकाधिक मार्कर मुझे Google मानचित्र में एकाधिक मार्कर जोड़ना है, लेकिन डेटा एक बाहरी जेसन फ़ाइल में है।Google मानचित्र - बाहरी जेसन
फिलहाल मैं इस
var json = [
{
"title": "Stockholm",
"lat": 59.3,
"lng": 18.1,
"description": "Stockholm is the capital and the largest city of Sweden and constitutes the most populated urban area in Scandinavia with a population of 2.1 million in the metropolitan area (2010)"
},
{
"title": "Oslo",
"lat": 59.9,
"lng": 10.8,
"description": "Oslo is a municipality, and the capital and most populous city of Norway with a metropolitan population of 1,442,318 (as of 2010)."
},
{
"title": "Copenhagen",
"lat": 55.7,
"lng": 12.6,
"description": "Copenhagen is the capital of Denmark and its most populous city, with a metropolitan population of 1,931,467 (as of 1 January 2012)."
}
];
for (var i = 0, length = json.length; i < length; i++) {
var data = json[i],
latLng = new google.maps.LatLng(data.lat, data.lng);
// Creating a marker and putting it on the map
var marker = new google.maps.Marker({
position: latLng,
map: map,
title: data.title
});
}
है जैसे कि यह चल रहा है अब एक दूसरी फ़ाइल में JSON फ़ाइल exlude की कोशिश कर रहा im, लेकिन sadyl मैं यह काम करने के लिए प्राप्त नहीं कर सकते, (
कोड
$.getJSON("foo.txt", function(json1) {
});
for (var i = 0, length = json.length; i < length; i++) {
var data = json[i],
latLng = new google.maps.LatLng(data.lat, data.lng);
// Creating a marker and putting it on the map
var marker = new google.maps.Marker({
position: latLng,
map: map,
title: data.title
});
}
foo.txt
{
"title": "Stockholm",
"lat": 59.3,
"lng": 18.1,
"description": "Stockholm is the capital and the largest city of Sweden and constitutes the most populated urban area in Scandinavia with a population of 2.1 million in the metropolitan area (2010)"
},
{
"title": "Oslo",
"lat": 59.9,
"lng": 10.8,
"description": "Oslo is a municipality, and the capital and most populous city of Norway with a metropolitan population of 1,442,318 (as of 2010)."
},
{
"title": "Copenhagen",
"lat": 55.7,
"lng": 12.6,
"description": "Copenhagen is the capital of Denmark and its most populous city, with a metropolitan population of 1,931,467 (as of 1 January 2012)."
}
आपकी मदद के लिए धन्यवाद
धन्यवाद आदमी, जो वास्तव में मदद की है: http: डी – Maxi
आप इस उपकरण के साथ JSON सिंटैक्स की जाँच कर सकते हैं: //jsonlint.com/ - उम्मीद है कि यह –
मदद करता है धन्यवाद, यह बिना किसी परेशानी या किसी भी बदलाव के काम करता है! – Danish