NetTalk Central

Author Topic: Nt8.10 Remove or update hand-coded marks from maps  (Read 3065 times)

jari@softmade.fi

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Email
Nt8.10 Remove or update hand-coded marks from maps
« on: April 28, 2014, 07:51:19 AM »
Hello

I can create mark with code:

   p_web.Script('$("#' & p_web._jsok(p_web.nocolon('MyMap')) & '").ntmap("addMarkerToCluster","'&p_web._jsok('Car')&'","_MyMARK_",'&p_web.GetLatLng(AJO:y)&','&p_web.GetLatLng(AJO:x)&','&p_web.WrapOptions(loc:options)&',"",0,2);')

But how can I remove or update mark?

This is not working:
 p_web.Script('$("#' & p_web._jsok(p_web.nocolon('MyMap')) & '").ntmap("removeMarker","_MyMark_");')

What am  I missing ???

Thanks

Jari

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Nt8.10 Remove or update hand-coded marks from maps
« Reply #1 on: April 28, 2014, 10:49:18 PM »
Hi Jari,

There are 2 kinds of markers on the map. Ones which are "clustered" and ones which aren't.

There's no "removeFromCluster" method at the moment, so I think you'd be best off using the addMarker method, not the addMarkerToCluster method to add the marker to the map in the first place.

Obviously then it won't "cluster" as you zoom out, but I'm going to guess that you don't want it to cluster anyway.

cheers
Bruce


jari@softmade.fi

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Email
Re: Nt8.10 Remove or update hand-coded marks from maps
« Reply #2 on: April 29, 2014, 03:53:52 AM »
Thanks Bruce

I tryed with this but not working.
p_web.Script('$("#' & p_web._jsok(p_web.nocolon('AccidentsMap')) & '").ntmap("removeMarker","_home_");')

There must be something in "_home_" part of code because  this works fine:

p_web.Script('$("#' & p_web._jsok(p_web.nocolon('AccidentsMap')) & '").ntmap("removeMarker","'&p_web.GetValue('_marker_')&'");')

.. and markers are clustered

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Nt8.10 Remove or update hand-coded marks from maps
« Reply #3 on: May 02, 2014, 07:11:02 AM »
Hi Jari,

I've tried to explain the process a bit here to remove some of the "unknowns".

In the Maps example,
General Map.
The CapeSoft Offices Marker has been added with the following JavaScript;

$("#GeneralMap").ntmap("addMarkerToMap","_home_",-34.041,18.47,{icon:blueMarker},"CapeSoft Offices", 1);

If you right click on the page, you'll see this in the source of the page.

That line of JavaScript was generated by the generated line of Clarion code;

    p_web.Script('$("#' & p_web._jsok(p_web.nocolon('GeneralMap')) & '").ntmap("addMarkerToMap","_home_",' & p_web.GetLatLng(-34.041) & ',' & p_web.GetLatLng(18.47) & ','&p_web.WrapOptions(loc:options)&',"'&p_web._jsok('CapeSoft Offices', Net:HtmlOk*0+Net:UnsafeHtmlOk*0)&'", 1);')


the maps widget is in jquery.nt-maps. This is a jQuery UI widget, and many of the JavaScript files follow this pattern.

addMarkerToMap is obviously the first method to inspect. The first parameter to this javascript method is bidv, which, as you correctly surmised is the marker "identifier". it is, incidentally, case sensitive.

there is a removeMarker method, but alas, it's removing from a cluster, not the "unclustered markers" (an oversight I'll need to fix.) which brings us back to your original post;

Notice you used _MyMARK_ when creating the marker and _MyMark_ when removing it.... Alsas, as mentioned it's case sensitive, which is why it didn't work.

sorry for not noticing that earlier.

cheers
Bruce





jari@softmade.fi

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Email
Re: Nt8.10 Remove or update hand-coded marks from maps
« Reply #4 on: May 03, 2014, 10:02:27 AM »
Thanks Bruce

I will check this

I would just like to add, move and delete markers without database saving.

I also try to use queue from data source, but failed that too.

Unknown identifier: X - C:\Clarion9\InvataksiC9\WEBajojarj\WEBajojarj011.clw:4402,10
Unknown identifier: X - C:\Clarion9\InvataksiC9\WEBajojarj\WEBajojarj011.clw:4403,18
Unknown identifier: X - C:\Clarion9\InvataksiC9\WEBajojarj\WEBajojarj011.clw:4405,65

After inserted X in local data I still did not get markers. I did not try this very seriously, so it can work anyway

Jari