You are not logged in.
Pages: 1
hello,
I have a problem of displaying markers to retrieve data from an external file. M Console returns this error and I do not know what I'm doing wrong:
error: invalid 'in' operand todo[property][i...
My data: (data.json)
{ "latitude":49.17698, "longitude":16.404793, "title":"Angered", "content":"Representing :)" },
{ "latitude":57.6969943, "longitude":11.9865, "title":"Gothenburg", "content":"Swedens second largest city" }My script:
$.post('http://localhost/data/data.json', function(data) {
$("#main-map").gmap3(
{ action:'init',
options:{
center:[49.196961,16.612644],
zoom: 7,
}
},
{ action: 'addMarkers',markers: data,
marker:{
options:{
draggable: false
},
events:{
click: function(marker, event, data){
var map = $(this).gmap3('get'),
infowindow = $(this).gmap3({action:'get', name:'infowindow'});
if (infowindow){
infowindow.close();
infowindow.open(map, marker);
infowindow.setContent(data);
} else {
$(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data}});
}
}
}
}
}
);
});
}you advise me, or is somewhere functional demonstration of retrieving data from an external file (txt, JSON).
thank you
Tomas
Offline
working simple json ajax markers demo
http://jsfiddle.net/charlietfl/S8kd3/
try changing "content" in your json object to "data"
Offline
Thanks,
I tried to change the UTR to load data in your example, but does not appear to me, a map but there is no error. We really do not know.
source data http://www.bambou.cz/data/data.json.htm
the problem is the data?
Offline
replace latitude by lat and logitude by lng (and no need the quote in property name):
{ lat:49.17698, lng:16.404793, ... },
{ lat:57.6969943, lng:11.9865, ... }
Offline
Pages: 1