michael kenny
Posts: 0
Joined: Tue Apr 02, 2013 2:47 pm

Google maps wont center

am building an app with a list of business on the first screen (info includes longtitude and latitude), click on business goes to second page showing where the business is and the directions. first time it works great. if i go back (using button) to first page and click same business again, the map is showing the south coast of england (not even near me) and zoomed out.

the directions are working fine, every time. its just the map that is screwed.

thanks in advance

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Google maps wont center

Hello! Please take a look here https://getsatisfaction.com/tiggzi/to.... Here you can find code to show markers, set zoom and center position.

michael kenny
Posts: 0
Joined: Tue Apr 02, 2013 2:47 pm

Google maps wont center

thats good stuff but.. when i go to the business page the first time i run the app the markers and directions, zoom and center are all correct. the problem arises when i go back to the first page and choose another business (or even the same business again)

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Google maps wont center

Could you send your public app link so we can test it?

michael kenny
Posts: 0
Joined: Tue Apr 02, 2013 2:47 pm

Google maps wont center

where do i find the public app link ?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Google maps wont center

Go to Test (check Public)
http://docs.tiggzi.com/documentation/... see Sharing app link

michael kenny
Posts: 0
Joined: Tue Apr 02, 2013 2:47 pm

Google maps wont center

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Google maps wont center

Add initialize map JS code on BusPage Show event, not Load

michael kenny
Posts: 0
Joined: Tue Apr 02, 2013 2:47 pm

Google maps wont center

put this in pageshow

initialize();
var myOptions = {
zoom :16,
center: new google.maps.LatLng(localStorage.getItem("LocLat"),localStorage.getItem("LocLong")),
mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map($('div[dsid="busMap"]').get(0), myOptions);

var marker = new google.maps.Marker({
position: new google.maps.LatLng(localStorage.getItem("LocLat"),localStorage.getItem("LocLong")),
map: map,
title: localStorage.getItem("LocBusName")
});

now i get this error.
Uncaught ReferenceError: map is not defined

i must have something in the wrong place.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Google maps wont center

Did you apply changes we suggested to public project? It seems there are no changes. Could you please try again? Delete Load event with this JS:

codeTiggr("busName").html(localStorage.getItem("LocBusName"));
Tiggr("busAddress").html(localStorage.getItem("LocAdd"));
Tiggr("busPhone").html(localStorage.getItem("LocPhone"));

var myOptions = {
zoom :16,
center: new google.maps.LatLng(localStorage.getItem("LocLat"),localStorage.getItem("LocLong")),
mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map($('div[dsid="busMap"]').get(0), myOptions);

var marker = new google.maps.Marker({
position: new google.maps.LatLng(localStorage.getItem("LocLat"),localStorage.getItem("LocLong")),
map: map,
title: localStorage.getItem("LocBusName")
});

//Tiggr("busMap").options.mapElement.gmap("refresh"); //trying to get the map to rewrite

Tiggr("offerTitle").html(localStorage.getItem("LocOffer"));
Tiggr("offerTxt").html(localStorage.getItem("LocOfferText"));
Tiggr("offerExp").html(localStorage.getItem("LocOfferExp"));

var sourceAddress = "176 Fernhill, Arklow, County Wicklow&quot
var destinationAddress = new google.maps.LatLng(localStorage.getItem("LocLat"),localStorage.getItem("LocLong"));
var panel= Tiggr("directionsPanel")[0];

displayDirections(sourceAddress, destinationAddress, map, panel);

console.log("back from displayDirections map.center="+map.center+" and map.zoom ="+map.zoom);/code

and put this code on Show event on BusPage page

Return to “Issues”