Moi
Osaisiko joku opastaa oikeaan suuntaan, kun haluaisin käyttää https://github.com/ValYouW/jqPropertyGrid Leaflet kirjastolla luodun karttamerkin muokkaamiseen?
Alla omaa räpellystä, jonka olen saanut nyt siihen asti, että lomake aukeaa popupiin, mutta uudet arvot eivät päivity karttamerkkiin.
var geojsonLayer = new L.GeoJSON(feature, {
onEachFeature: function (feature, layer) {
console.log(feature.properties);
var cb = function (grid, name, value){
console.log('cb',grid,name,value);
feature.properties[name] = value;
}
var editor = L.DomUtil.create('div', 'featurePropertyGrid');
editorGrid = $(editor);
$(editorGrid).jqPropertyGrid(feature.properties, {callback: cb, meta: theMeta});
layer.bindPopup(editorGrid[0]);
layer.bindTooltip(feature.properties.name);
}
}).addTo(map);Ilmeisesti päivittyneet arvot pitäisi erikseen noutaa:
var theNewObj = $('#propGrid').jqPropertyGrid('get');jotta ne voi asettaa. Ideoita, että miten tuon toteuttaisi?
Lisäsin tuon tooltip toiminnon, jotta voisin helposti todeta arvojen tilan.
Method bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?) Returns this Description Binds a popup to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.
Lisäys:
Viimeisin versio kaatuu jqPropertyGrid('get') kutsun myötä virheeseen:
Error: cannot call methods on spinner prior to initialization; attempted to call method 'value'
var geojsonLayer = new L.GeoJSON(feature, {
onEachFeature: function (feature, layer) {
function cb(grid, name, value){
console.log('cb',grid,name,value);
}
var editor = L.DomUtil.create('div', 'featurePropertyGrid');
editorGrid = $(editor);
$(editorGrid).jqPropertyGrid(feature.properties, {callback: cb, meta: theMeta});
$('.pgCell > input', editorGrid).change(function(evt){
console.log(JSON.stringify($(this).closest('div.featurePropertyGrid').jqPropertyGrid('get'), null, '\t'));
});
layer.bindPopup(editorGrid[0]);
layer.bindTooltip(feature.properties.name);
}
}).addTo(map);Aihe on jo aika vanha, joten et voi enää vastata siihen.