am more comfortable with programming using javascript plus i like the error checking support on DS. if there is an error in the script we can get the line position of the error. i dont like to do sending of data (injecting data to html) using web.Execute(). what i did is using the sample here i the forum where html communicate with your js app by sending json obj data back and forth. it works but my main problem is there is no support on error checking on the html side. if i miss just a comma "," on a object like this
var obj={
"test": 123 <--- comma missing here
"test2": "text"
}
the leaflet html wont load properly. and its hard to search around the code for the TINY error.
but if this works the plugin you can use javascript to make a window of the leaflet map and any map action it will pass to your javascript app. then you can issue command in js ide normally the plugin handles the communication to the HTML map for you.
example making a mapclick action youdont need to code on the html map.on('click',onMapClick);
instead you can do this in js on ds side by simply calling
mapclick(handleClick);
function mapclick(callback){
//pass command to html map.setting up callback
}
when user click the map you will get an obj that has
obj{cmd:'mapclick',lng:51.5,lat:-0.09}
with that json obj you can do whatever you want
just want to make interfacing with html map easier but the html error checking support is really no support. the map just wont load and finding the tiny error takes a lot of time.
any ideas to make this easier (finding error on html side) ?
Currently i have coded access to leaflet map (18methods), getting map state(10methods), marker(9methods), currently doing popup.
Here is the brick wall... Some of leaflet methods returns an object or reference link. I kept trying "TO SEND" the obj link back to ds app, tried a few methods. All failed. The link disaappears during transfer. Cant use json stringify on it. Cant use app.savetext am stump on how to transfer the reference link beacuse its needed when you need to perform other methods. Example when you create a marker the result output is an obj. Later you need the obj to call a remove (if you want to remove it)
Anybodu here have any idea on how to do this? Transfer obj pointer reference from html form to ds app.
to add;
web.Execute("o = L.marker(["+lat+,+lon+"]).addTo(map);");
to remove;
web.Execute("map.removeLayer(o)")
Like getting icon file
Setting is no problem like this
web.Execute("icn.setIcon("+<icon file>+");");
How about getting a reply?
web.Execute("icn.getIcon()");
So where can i get the result of getIcon() command?
Then use a parsed json data string.
//WebView
var data = {
type:"result1",
value:"myValue"
};
console.log(JSON.stringify(data));
//Main App
function WebView_OnConsole(data)
{
var data = null;
try{
data = JSON.stringify(data);
}catch(e){}
if(!data)
return;
switch(data.type)
{
case "result1": {app.Alert(data.value);} break;
case "result2": {/*do something*/}break;
}
}
I hope that helps.
On this sample the type is a string. It wont work if its a value output.
//WebView
var data = {
type:"result1",
value:"myValue"
};
console.log(JSON.stringify(data));
//Main App
function WebView_OnConsole(data)
{
var data = null;
try{
data = JSON.parse(data);
@oreste
Thanks for the sample. Still have not implemented a circle code on it but i need a marker icon code. I want to replace the standard marker icon. Example the standard icon showing where you are is a reverse droplet icon. I have an icon of a hamburger (showing as fastfood) and use it as a marker for a pint on a place instead of the reverse droplet icon.
Anybody who can show me how its done. A working code would be helpful. Thanks