...

View Full Version : Invalid Property id



draive
02-27-2009, 02:57 AM
Well, I have pulled out my last hair. Been trying to debug this for 2 days. Can someone take a quick look at this code and perhaps point me to a resolution?

The error is:


invalid property id
[Break on this error] loadJsonMarkers({"data":[{"myname":"asdf...e":"sdfsdf","latitude":-0.323957626559,"

The relevant javascript is:


function grabJsonMarkers() {
// Retrieve the JSON feed.
var script = document.createElement('script');
script.setAttribute('src', '/json?callback=loadJsonMarkers');
script.setAttribute('id', 'jsonScript');
script.setAttribute('type', 'text/javascript');
document.documentElement.firstChild.appendChild(script);
// alert("done getting");
}

function loadJsonMarkers(json) {
var bnds;
var ts = "";// timestamp field of most recent marker pin (not deleted)
alert("loading json");

// omit the duplicates (by name) using an association table

for ( var i = 0; i < json.data.length; i++) {
var entry = json.data[i];

// a pinned marker must have a name
var name = entry['myname'];
alert(name)
if (name == null)
continue;
if (name == "")
continue;
// get lat/lon
var e = NaN;
var n = NaN;

if ((entry['latitude'] != null) && (entry['longitude'] != null)) {
e = parseFloat(entry['longitude']);
n = parseFloat(entry['latitude']);
}
if (isNaN(e) || isNaN(n)) {
continue;// cant put marker on map without a lat/lon
}
var en = new GLatLng(n, e);

// find bounds of loaded markers
if (bnds == null)
bnds = new GLatLngBounds(en, en);
else
bnds.extend(en);

var type = entry['mytype'] + "";
var by = entry['by'];
var update = entry['update'];
notes = new Array();
for ( var c = 0; c < entry['notes'].length; c++) {
var note = entry['notes'][c];
note.text = note.text.replace(/&lf;/g, "\n<br>");
note.text = note.text.replace(/&cr;/g, "\r");
var cs = note.text + "<br><i>" + note.by + " - " + note.timestamp
+ "</i>"
notes.push(cs);
}
addMarker(en, name, type, notes, by, update); // pin the marker on the
// map
ts = entry['timestamp'];
}

// pan map to bounds
if (bnds != null) {
var z = map.getBoundsZoomLevel(bnds);
map.setCenter(bnds.getCenter(), z - 1);
}

}

Which uses a tad bit of python:


class Json(webapp.RequestHandler):
def get(self):

cb = self.request.get('callback')
if cb:
self.response.out.write (cb)
self.response.out.write ('(')


markers = db.GqlQuery("SELECT * "
"FROM Marker "
"ORDER BY timestamp ASC LIMIT 200")

self.response.out.write('{"data":[')

i = 0
for marker in markers:
if i > 0:
self.response.out.write(',')
i = i+1
self.response.out.write('{"myname":"%s",' % marker.myname)
self.response.out.write('"latitude":%s,' % marker.latitude)
self.response.out.write('"longitude":%s,' % marker.longitude)
self.response.out.write('"mytype":"%s",' % marker.mytype)
self.response.out.write('"notes":"%s",' % marker.notes)
self.response.out.write('"timestamp":"%s",' % marker.timestamp.strftime("%d-%m-%y %H:%M:%S"))
if marker.pinnedBy:
self.response.out.write('"by":"%s",' % marker.pinnedBy.nickname())
if users.is_current_user_admin():
self.response.out.write('"update":true,')
elif marker.pinnedBy == users.get_current_user():
self.response.out.write('"update":true,')
else:
self.response.out.write('"update":false,')
else:
self.response.out.write('"by":"Anon",')
if users.is_current_user_admin():
self.response.out.write('"update":true,')
else:
self.response.out.write('"update":false,')

As far as the code that puts it in the DB (google app engine) that seems to work just fine. I could post that code too if needed.

draive
02-27-2009, 06:07 AM
nevermind, fixt.

durgapavani
03-30-2010, 08:07 PM
Hello draive,

I am stuck with the same problem. Could you please post how you resolved yours??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum