Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

Google maps wont center

Hi Katya

Now this is very strange! it worked 5 days ago and now the problem seems to have reappeared. I still have Apperyio("google_map1").refresh(); on page show which is triggered after the marker points are plotted on the map.

I've plotted just one point in barcelona to show as an example and provided a screen shot

Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Google maps wont center

Hi Shawn,

Please try these solutions:
http://stackoverflow.com/questions/10...

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

Google maps wont center

Hi

I seem to have solved the google map cropping problem but am now facing a slightly different challenge.

I'm calling the initialize() function on page load with a timeout of 50 but it seems to be taking quite some time to finish is there any way to wait till completion ?
Because subsequent marker calls like map.fitBounds(bounds) is failing as map' isn't getting initialized . Please note : For me 'Render all pages in one HTML file' is ON

Here is the code again

function initialize()
{
console.log('Initializing Map...');

Code: Select all

 map = Apperyio("google_map").gmap; 
 if (!map) { 
     setDelay(); 
 }  

}

function mylocationmarker()
{
var iconBase = 'https://maps.google.com/mapfiles/kml/...';
var markerLatLng = new google.maps.LatLng(localStorage.getItem('markerLat'), localStorage.getItem('markerLng'));

var marker = new google.maps.Marker({
position: markerLatLng,
map: map,
title: 'My position',
animation: google.maps.Animation.DROP,
icon: iconBase + 'man_maps.png'
});

markers.push(marker);
bounds.extend(markerLatLng);
map.fitBounds(bounds);
}

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

Google maps wont center

Also tried calling initiatlize() on Page Show

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

Google maps wont center

Hi Shawn,

Please replace your code:

pre

map = Apperyio("google_map").gmap;

/pre

with following one:

pre

var map = Appery("google_map").options.mapElement.gmap('get', 'map');

/pre

Regards.

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

Google maps wont center

Gives an Error 'Uncaught TypeError: Cannot read property 'options' of undefined'
and hangs the system. Here is the code ...

var directionsDisplay;
var map;
var markers = [];
var directionsService = new google.maps.DirectionsService();
var bounds = new google.maps.LatLngBounds();
var trafficLayer = new google.maps.TrafficLayer();

function initialize()
{
console.log('Initializing Map...');

Code: Select all

 map = Appery("google_map").gmap.options.mapElement.gmap('get','map'); 
 if (!map) { 
     setDelay(); 
 }  

}

function setDelay() {
setTimeout(initialize, 50);
}

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

Google maps wont center

Hi Shawn,

You currently use code:

pre

map = Appery("google_map").gmap.options.mapElement.gmap('get','map');

/pre

But i've provide you with following one:

pre

var map = Appery("google_map").options.mapElement.gmap('get', 'map');

/pre

Please use given code, don't try to change it.

Regards.

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

Google maps wont center

Oops that was an early morning fix without any coffee :)
Your code has worked, Thanks Yurii

Cristian Hidalgo
Posts: 0
Joined: Mon Nov 03, 2014 2:38 pm

Google maps wont center

Page not found :(

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Google maps wont center

Hi Cristian,

What exactly page is not found?

Return to “Issues”