javascript - How do I update a Google Map Engine Table? -


i have table in google maps engine update dynamically javascript in google site. i've found this page explains how append features existing table, i'm struggling figure out how modify code update table instead of append it. believe need modify processresponse , processerrorresponse functions. however, i'm new javascript/jquery/json, , i'm not sure how determine should have instead of #insert-table-features-response. there here explain me?

edit: put way, how can make request shown below javascript?

post https://www.googleapis.com/mapsengine/v1/tables/{your_table_key}/features/batchpatch?key={your_api_key}  content-type:  application/json authorization:  bearer {. . .} x-javascript-user-agent:  google apis explorer  {  "features": [   {    "geometry": {     "type": "point",     "coordinates": [      -82,      35     ]    },    "properties": {     "lat": 35,     "long": -82,     "name": "6:41:13 11/27/14",     "gx_id": "123abc456def7890"    }   }  ] } 

rather try , squeeze comment on jpatokal's answer, i'll throw in answer.

as said, want use batchpatch request, rather batchinsert. check out docs here: https://developers.google.com/maps-engine/documentation/reference/v1/tables/features/batchpatch

if you're using js provided in docs, code on page linked includes function:

function inserttablefeatures(tableid) {   dorequest({     path: '/mapsengine/v1/tables/' + tableid + '/features/batchinsert',     method: 'post',     body: {       features: cities     },     processresponse: function(response) {       $('#insert-table-features-response').text(           json.stringify(response, null, 2));     },     processerrorresponse: function(response) {       $('#insert-table-features-response').text('error response:\n\n' +           json.stringify(response, null, 2));     }   }); } 

you want change path batchinsert batchpatch , update body: { ... }. can replace body of http request provided so:

function updatetablefeatures(tableid) {   dorequest({     path: '/mapsengine/v1/tables/' + tableid + '/features/batchpatch',     method: 'post',     body: {      "features": [       {        "geometry": {         "type": "point",         "coordinates": [          -82,          35         ]        },        "properties": {         "lat": 35,         "long": -82,         "name": "6:41:13 11/27/14",         "gx_id": "123abc456def7890"        }       }      ]     },     processresponse: function(response) {       // you'll want change these       $('#insert-table-features-response').text(           json.stringify(response, null, 2));     },     processerrorresponse: function(response) {       // you'll want change these       $('#insert-table-features-response').text('error response:\n\n' +           json.stringify(response, null, 2));     }   }); } 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -