Xavier
Posts: 0
Joined: Wed Oct 29, 2014 8:09 pm

Map centering when performing a mapping

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Map centering when performing a mapping

Hello Xavier,

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

Xavier
Posts: 0
Joined: Wed Oct 29, 2014 8:09 pm

Map centering when performing a mapping

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Map centering when performing a mapping

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.

Xavier
Posts: 0
Joined: Wed Oct 29, 2014 8:09 pm

Map centering when performing a mapping

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Map centering when performing a mapping

Xavier,

Could you please show us the code that you use?

Xavier
Posts: 0
Joined: Wed Oct 29, 2014 8:09 pm

Map centering when performing a mapping

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Map centering when performing a mapping

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.

Xavier
Posts: 0
Joined: Wed Oct 29, 2014 8:09 pm

Map centering when performing a mapping

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Map centering when performing a mapping

Hi Xavier,

As i can see you commented one line of code.

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

Regards.

Return to “Issues”