Announcement

Collapse
No announcement yet.

Help with extracting coordinates: string\matchAll or string\matchExtract

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with extracting coordinates: string\matchAll or string\matchExtract

    Hello all,

    I use an extension from Eblasoft called Ebla Map Plus (wonderful extension btw!) and I can add polygon shapes to google maps. It saves this in a field "fieldname_draw_data" in the format:
    {"polygons":[[{"lat":52.00000000000000,"lng":5.000000000000000}, {"lat":52.00000000000000,"lng":5.000000000000000}, {"lat":52.00000000000000,"lng":5.00000000000000 0},]]}

    Since i cant print this polygon with "printtopdf" in any way and the developer currently doesn't have time to add this, I tought i would use formula to create a url with the google maps static API.Then i can use this with the image tag in my pdf template.

    In order to do this, i need to reformat the draw data in the following format:
    52.00000000000000,5.000000000000000|52.00000000000 000,5.000000000000000|52.00000000000000,5.00000000 0000000|52.00000000000000,5.000000000000000

    I think it should be achievable to do this with string\matchAll or string\matchExtract but i don't know how exactly. Anybody able to point me in the right direction?

  • #2
    You can do that with string/concatenate, taking the single coordinates and add your pipe or whatever you need as plain text parts. It will have a lot of commas and needs a bit experimenting.
    But I succeed to format a google address even without API.

    Comment


    • #3
      Eventually i did the following formula and this works for now:

      $poly1 = json\encode(locatieDrawData);
      $poly2 = string\replace($poly1,'{"polygons":[[','&path=color:0x00e0ff|weight:5|fillcolor:0x00e0f f' );
      $poly3 = string\replace($poly2,'{"lat":','|');
      $poly4 = string\replace($poly3,'"lng":','');
      $poly5 = string\replace($poly4,'},','');
      $poly6 = string\replace($poly5,'],[','&path=color:0x00e0ff|weight:5|fillcolor:0x00e0f f' );
      $poly7 = string\replace($poly6,'}','');
      $poly8 = string\replace($poly7,']','');
      locmap3 = string\concatenate("https://maps.googleapis.com/maps/api/staticmap?maptype=satellite&size=360x280&key=XxXx& markers=color:red|",locatieLatitude,",",l ocatieLongitude,$poly8);​

      Comment


      • #4
        Hi mbrands

        I have just noticed your post, my email notifications not working on forum for some reason, we will try to implement this feature asap on March, will announce here when done.

        Best regards
        CEO of Eblasoft
        EspoCRM Expert since 2014
        Full Stack Web Developer since 2008
        Creator of Numerous Successful Extensions & Projects​

        Comment

        Working...
        X