I want to create a Google Map dynamicly by loading data per AJAX. Therefore I use a JSON object with the identically structure of the GM API to build the map and jQuery to load per AJAX.
Like:
"object": {
"div": "map1",
"options": {
"center": {
"latitude": 38.608202,
"longitude": 26.373749,
"noWrap": false
},
"mapTypeId": "roadmap",
"zoom": 7
}
}
Will it be now a good idea to have also raw JavaScript in the JSON and parse it with the eval function like:
"object": {
"div": "map1",
"options": {
"center": new google.maps.LatLng( 38.608202, 26.373749 ),
"mapTypeId": google.maps.MapTypeId.ROADMAP,
"zoom": 7
}
}
With the default JSON parser of jQuery I get an error. But if I create my own converter with the eval function, it works.
jQuery.ajax({
url: this.url,
data: this.parameters,
type: method,
dataType: 'json',
converters: {'text json': function( data ){
eval( 'data = ' + data );
return data;
}},
[…]
});
I know this will not be a correct JSON format. But will I get some other troubles whith this, or is there any speed loss cause the eval function?