Page 1 of 1

Map centering when performing a mapping

Posted: Sat May 09, 2015 1:38 am
by Xavier

Hi,

My app have a non common behavior :-(

I have:

  • a Gmap with a default location set to 'Paris,Fr'

  • a button which invoke a mapping from a storage list to a MobilList

    Each time I I click the button, the map centers to 'Paris,Fr'.

    What I do not understand is that the button, the stored list and the MobilList do not have anything to do with the Gmap.

    I can reproduce the error at each try.
    Can you tell me how to avoid this behavior ?

    Thanks in advance :-)
    Kind regards
    Xavier


Map centering when performing a mapping

Posted: Sat May 09, 2015 5:29 am
by Evgene Karachevtsev

Hello Xavier,

Could you please clarify how do you set the default location to Paris in your app?


Map centering when performing a mapping

Posted: Sat May 09, 2015 8:59 am
by Xavier

Hi Evgene,

You are right, this is not a 'default location'.
I entered 'Paris,Fr' in the Gmap 'Address' field provided by Appery.

Even if I move the map, it re-centers to this address each time I click the button.

Thanks for your help
Xavier


Map centering when performing a mapping

Posted: Sat May 09, 2015 11:46 am
by Evgene Karachevtsev

Xavier,

You may remove it from the Address field and set position via js code and call this code on page load event of the page.


Map centering when performing a mapping

Posted: Sun May 10, 2015 2:14 am
by Xavier

Hello Evgene,

I made what you proposed:

  • I removed 'Paris,Fr' from the address field

  • I put a java script code to change the center of the map when the screen loads.

    Nevertheless, the issue keeps on occuring.
    Now when I click the button, the map centers at a 0/0 Latitude/Longitude point.

    Do you have any idea to avoid this ?

    Thanks in advance
    Best regards
    Xavier


Map centering when performing a mapping

Posted: Sun May 10, 2015 4:39 pm
by Evgene Karachevtsev

Xavier,

Could you please show us the code that you use?


Map centering when performing a mapping

Posted: Mon May 11, 2015 12:36 am
by Xavier

Hi Evgene,

Here is the code I use on screen oad:

Appery("googlemap_57").options.mapElement.bind('init',function(evt, map) {

var omap = Appery("googlemap_57").gmap;
var latLngParis = new google.maps.LatLng(48.8534100, 2.3488000);
omap.panTo(latLngParis);
omap.setZoom(13);

});

Best regards
Xavier


Map centering when performing a mapping

Posted: Tue May 12, 2015 2:49 am
by Yurii Orishchuk

Hi Xavier,

Please use following JS code to set map component settings:

pre

Appery("googlemap_57").options.mapElement.bind('init',function(evt, map) {

Code: Select all

var map = Appery("googlemap_57"); 
map.options.latitude = 48.8534100; 
map.options.longitude = 2.3488000; 
map.options.address = ''; 
map.options.mapElement.gmap( 
   { 'center': new google.maps.LatLng(48.015883, 37.80285), 'zoom': 5} 
); 
map.refresh(); 

});

/pre

Regards.


Map centering when performing a mapping

Posted: Tue May 12, 2015 8:52 am
by Xavier

Hi Orishchuk,

Here is the JS code I used:

var omap = Appery("googlemap_57");
omap.options.latitude = 48.8534100;
omap.options.longitude = 2.3488000;
omap.options.address = '';

// I tested with and without the following line
// omap.options.mapElement.gmap( { 'center': new google.maps.LatLng(48.015883, 37.80285), 'zoom': 5} );

Code: Select all

 omap.refresh(); 

Nevertheless, it has the same behavior as the original problem:

  • it centers t Paris at the screen load

  • I can move the map to look at the place I want

  • each time I click on a button that perform a matching (which has nothing to do with Gmap) it centers the map in Paris (whereas I would like it to stay at the same place.

    Is there any other way to avoid this issue ?

    Thanks in advance
    Best regards
    Xavier


Map centering when performing a mapping

Posted: Fri May 15, 2015 1:50 am
by Yurii Orishchuk

Hi Xavier,

As i can see you commented one line of code.

Details: http://prntscr.com/75c8oy/direct

Regards.