cancel
Showing results for 
Search instead for 
Did you mean: 

Change Spot Location

nicholas_arent
Explorer
0 Kudos

Hi,

I am having an issue where after I've loaded a map I would like to change a spots location. I have been doing this by setting new Config data but this has been causing an exception (Cannot read property 'slice' of undefined) while also blanking out the map.

Then I saw the post here:

Which I feel is probably related to my problem.

So my question is, once a map has been loaded once, is it possible to change the location of a set spot and also move a map to reflect the spots new location?

Best Regards,

Nick

Accepted Solutions (1)

Accepted Solutions (1)

nicholas_arent
Explorer
0 Kudos

Rereading my post I thought I would elaborate a bit more. I am using the AnalyticMap component and have configured a spot on the map in the configuration JSON data.

I noticed in the GeoMap there is an api call(getVos) that seems to get the spot data among other configured VO's, but I don't see an equivalent call for AnalyticMap. Is it possible to change an AnalyticMap's configured spot location after the map has been loaded?

Here is a small snippet of the config code for the spot:

{

  "SAPVB": {

  "Resources": {

  "Set": {

  "Resource": [

      {

      name:"blue_dot.png",

          value:<long image value>     }

  ]

  }

  },

  "Data": {

  "Set": {

  "N": [

  {

  "name": "Regions",

  "E": []

  },

  {

  "name": "Circles",

  "E": [

  ]

  },

  {

  name : "Spots",

  E : [

  {

  pos : "8.64;49.25;0"

  }

  ]

  }

  ]

  }

  },

And then lower down in the scenes section there is this:

{

  id : "Spot",

  type : "{00100000-2012-0004-B001-64592B8DB964}",

  datasource : "Spots",

  image : "blue_dot.png",

  "pos.bind" : "Spots.pos",

  text : "",

  tooltip : "",

  fxdir : "true",

  fxsize : "true",

  scale : "1;1;1",

  hotScale : "1.2;1.2;1.2"

  }

Best Regards,

Nick

former_member182119
Active Participant
0 Kudos

Hello Nick,

changing data works always the same way. It is described here: http://scn.sap.com/docs/DOC-57043

A precondition is that you use binding in the VO, which you do. Then you can add, remove, and change data entries as given in the article by sending smal JSON snippets to the control.

Best regards,

Uwe

nicholas_arent
Explorer
0 Kudos

Hi Uwe,

Thank you for your quick reply, this looks good. The only thing I cannot figure out is how to set the small json snippets. I've been using analyticMap.setConfig(jsonSnippet), but this keep throwing a "Cannot read property 'slice' of undefined exception. So, am I doing this wrong?

Regards,

Nick

Former Member
0 Kudos

Hi Nicolas,

when you use the AnalyticMap you should use the provided UI5 interface for ite. Modifying the initial application is possible but will very likely not work with our next version. We are doing changes there and we test only the official interfaces.

Regards, Uli

Nevertheless these are the steps that might help you:

1.) Hook the initial application

    jQuery.sap.require( "sap.ui.vbm.AnalyticMap");

     sap.ui.vbm.AnalyticMap.DefaultApplicationURL = "my_analyticmap.json";

2.) Modify the original file in the VO and data section as you did it in your snippet. Keep the elements (E) empty.

3.) Additionally you have to enhance the DataType section. Provide a key entry to be able to modify only a specific spot!

{

     "name": "Spots",

     "key": "Key",

     "A": [

     {

          "name": "Key",

          "alias": "K",

          "type": "string"

     },

     {

           "name": "pos",

           "alias": "P",

           "type": "vector"

     }

}

4.) Now you can  load() the following JSON to fill the Spots table:

      {

          "SAPVB": {

          "Data": {

               "Set":

               {

                    "type": "N",

                    "name": "Spots",

                    "N": {

                           "name": "Spots",

                           "E": [

                              {  "K" : "1", P":"8.64;49.25;0" },

                              {  "K" : "2", P":"8.64;70.35;0" }

                              ]

               }

        }

 

Remark: The current version of the AnalyticMap might delete the spots whenever something is changed in the applied binding model.

nicholas_arent
Explorer
0 Kudos

Hi Uwe and Ulrich,

Thanks for the replies, this now works for me.

Best Regards,

Nick

Answers (0)