Page 1 of 3

Build map , call service to update data , return - map is 'lost'....

Posted: Wed Nov 19, 2014 8:49 pm
by Bruce Stuart

i've been working for over 8 hours on this problem and time to call in the experts.

In my app, on a UI where I have a map, and I am dropping markers based on user input, the app:

  1. Creates a map and drops markers based on data in a db (works great)

  2. Prompts the user if s.he would like to add new markers, if so - gathers input, drops a new marker, and updates the DB for the new marker. I use a rest service to udpate the DB.

  3. After calling the rest-service - exactly between the Javascript I run before the service executes mappings and updates the DB - and running the success event on the way back - my 'map' loses it's mind (the center moves to somewhere out in the Indian ocean (not desired lol) - and turns black (since there is no data for zoom 17 where it(the map) lands).....i've tried dealing with the after effects and just resetting the map center - still no luck.

    if I take out the call to the data service - life is good and the map stays fine. I'm gathering data in a popup - writing the marker on the map, and then calling the rest service to update the data.

    It appears that the framework has code in the event to update the DB that tries to show-hide my controls.... from the interpreted code in my debugger I see:

    Apperyio.CurrentScreen = 'page_holedetail';
    _.chain(Apperyio.mappings).filter(function(m) {
    return m.homeScreen === Apperyio.CurrentScreen;
    }).each(Apperyio.UIHandler.hideTemplateComponents);

    Is this or some other event causing my ill-desired behavior? if so - how do I work around it? I've tried changing the timing of this event , waiting till my popup closes and writing the data - the result is the same - calling a rest service to udpate data when my map is showing - causes this 'blackout' effect.

    Best,

    Bruce


Build map , call service to update data , return - map is 'lost'....

Posted: Wed Nov 19, 2014 9:43 pm
by Maryna Brodina

Hello!

Instead success try using complete event. Please post screenshots of service mapping you use. Map shouldn't move for no reason...


Build map , call service to update data , return - map is 'lost'....

Posted: Wed Nov 19, 2014 10:24 pm
by Bruce Stuart

Maryna,

Thanks for the quick reply.

Here's a few more details. I gather information in a popup window that is 'on-top' of the map, when the user clicks 'drop marker' (essentially the 'OK' button on the popup) --- I kick off the events to drop the marker on the page.

Without the call to my rest service - the popup closes, the pin-marker (that has amination turned on ) - drops gracefully from the top of the map - onto the desired place on the map.

When the rest - service is invoked - from the button click - that's where the fallout occurs. I've put debugging code in the rest-service to see where the map loses it's mind - and it's between the before mapping - and the return in the success .

The mapping is very simple and has little logic. here is the code from the Javascript before launching the map (includes my feeble attempt at saving the center ) :

(of note - since the event to write data to the db has no impact on the map - ui - there is no mapping in the success event - see attached)....

Javascript in the before updating event:
Image

The Mapping used to update the data:
Image

The Script in each one of the items with the 'blue' JS indicator - in order:

Image

Image

Image

Image


Build map , call service to update data , return - map is 'lost'....

Posted: Wed Nov 19, 2014 10:30 pm
by Bruce Stuart

continued...

Image

mapping on success (no mapping since the success does not impact the UI)
Image

javascript in the complete event:

Image

and code that kicks all this off (from the OK button on my popup):

// call the services to update the records...
if ( localStorage.getItem('bdoupdate') ) {

Code: Select all

 var sselected = Appery('select_markertype').val(); 
 if ( sselected === "T" || sselected === "G" ){ 

service_updateholedata.execute();
}
else {
service_writenewholerecord.execute();
}
}

// editorially - both events (the updateholdate and the writenewholerecord both cause the map disfunction - and contain different mappings and different JS code...
but both are very simple update methods....


Build map , call service to update data , return - map is 'lost'....

Posted: Thu Nov 20, 2014 2:44 pm
by Bruce Stuart

Has anyone had a chance to look at this issue?


Build map , call service to update data , return - map is 'lost'....

Posted: Thu Nov 20, 2014 2:53 pm
by Evgene Karachevtsev

Hello Bruce,

Sorry for delay, we are working on it and will get back to you with the update.


Build map , call service to update data , return - map is 'lost'....

Posted: Thu Nov 20, 2014 3:19 pm
by Bruce Stuart

Evgene ,

Thanks so much... Let me know if you need any other code snippets or any help reproducing the problem..thanks again... Bruce


Build map , call service to update data , return - map is 'lost'....

Posted: Thu Nov 20, 2014 10:11 pm
by Alena Prykhodko

You may have problems because service and javascript work with map at the same time. Try to create sequence instead of parallel execution.


Build map , call service to update data , return - map is 'lost'....

Posted: Thu Nov 20, 2014 10:53 pm
by Bruce Stuart

Alena,

thanks for the reply. I'm not sure I understand what you are asking me to do, and what the benefit is.

You're saying I should 'wait' for execution of one to complete (say the map update) and then execute the database update? Make them serial instead of parallel ?

I'll do that now assuming that's what you are asking for - and post results within the next hour.

Thanks....

Bruce


Build map , call service to update data , return - map is 'lost'....

Posted: Thu Nov 20, 2014 10:57 pm
by Alena Prykhodko

Yes, correct.