Page 6 of 6

How do I remove map markers?

Posted: Wed May 20, 2015 10:43 pm
by Joe Sharples

I tried your code on page load:

pre
Appery("googlemap_57").options.mapElement.bind('init',function(evt, map) {
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

I received the error:
Uncaught TypeError: Cannot read property 'getBounds' of null

The only component on the page is the map.
the only event is this page load event.

Image

Image

I've also tried it with no Latitude or Longitude values in the Properties panel.
I got the error again.


How do I remove map markers?

Posted: Tue May 26, 2015 6:57 am
by Joe Sharples

Any idea what is causing this?


How do I remove map markers?

Posted: Sun May 31, 2015 8:36 am
by Alena Prykhodko

Hello Joe,

Sorry for delay here. We'll reply as soon as possible.
This will take time.


How do I remove map markers?

Posted: Tue Jun 02, 2015 4:23 pm
by Joe Sharples

Thank you


How do I remove map markers?

Posted: Fri Jun 05, 2015 1:16 am
by Yurii Orishchuk

Hi Joe,

So this code works correctly?

Your map navigates to "Paris" as you want?

The problem you have is "Error in console"?

If so please show us how you set map component and marker component. (screen shout of properties for these components).

Thanks.


How do I remove map markers?

Posted: Mon Jun 15, 2015 4:57 pm
by Joe Sharples

yes everything works fine now, setting the map marker, setting directions from current location and clearing markers.
But i still receive the error.

on page show I have a read database service (Info_Rest) that populates components on the page (such as labels). also the Address is mapped to local storage.
Image

on service success a 'convertAddress' is invoked.

Image

Image

Image

On success JS is run:
codeinitializeN();/code

JS file:
pre

var mapN;
var boundsN = new google.maps.LatLngBounds();
var mapN = Appery("googlemapNight").gmap;
var directionsServiceN = new google.maps.DirectionsService();
var boundsN;
var directionsDisplayN = new google.maps.DirectionsRenderer();

function displayDirectionsN(sourceAddress, destinationAddress, mapN) {
var request = {
origin: sourceAddress,
destination: destinationAddress,
travelMode: google.maps.DirectionsTravelMode.DRIVING,

Code: Select all

 }; 
 directionsServiceN.route(request, function(response, status) { 

directionsDisplayN.setMap(mapN);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplayN.setDirections(response);
} else {
alert("Directions query unsuccessful. Response status: " + status);
}
});

}

var mlatN = localStorage.getItem('markerLatN');
var mlngN = localStorage.getItem('markerLngN');

function initializeN() {
var mapOptions = {
zoom: 16,
center: new google.maps.LatLng(mlatN, mlngN)
};
mapN = new google.maps.Map(document.getElementById('NightInfo_googlemapNight'),
mapOptions);

var markerLatLng = new google.maps.LatLng(localStorage.getItem('markerLatN'), localStorage.getItem('markerLngN'));

var marker = new google.maps.Marker({
position: markerLatLng,
map: mapN,
animation: google.maps.Animation.DROP
});

mapN.setCenter(markerLatLng);
mapN.setZoom(14);

/pre

I also have another button 'getDirections' on the page that uses a geolocation service and displays directions.

Image

on success JS:
pre
var mapN = new google.maps.Map(document.getElementById('NightInfo_googlemapNight'));

var directionsServiceN = new google.maps.DirectionsService();
var boundsN;
var directionsDisplayN = new google.maps.DirectionsRenderer();

var GeoLatN = localStorage.getItem('GeoLat');
var GeoLngN = localStorage.getItem('GeoLng');

var GeoLatLngN = GeoLatN + ", " + GeoLngN;
var DestinationLatLngN = new google.maps.LatLng(localStorage.getItem('markerLatN'), localStorage.getItem('markerLngN'));

var sourceAddress = GeoLatLngN;
var destinationAddress = DestinationLatLngN;
displayDirectionsN(sourceAddress, destinationAddress, mapN);
/pre

I also have a 'clearDirections' button to clear the directions:
pre

directionsDisplayN.setMap(null);
initializeN();
/pre

When the page shows I receive the error:
Image

If I click the getDirections button i don't receive the error again.
If I click the clearDirections I don't receive the error again.
I added a 2 test buttons. one to invoke the 'Info_Rest' service and one to invoke the 'convertAddress' service.

If i click the convertAddress button I don't receive the error again.
If I click the Info_Rest button I DO receive the error.

Info_Rest service in detail:
before:
Image

on success:
Image

Image

Night description JS:
pre
if(!value) {
return ("");
}
/pre

All the GRID_X elements have very similar JS:
for example
GRID_DAY js:
pre
console.log("Day = " + value.Day);
if(value.Day){
Apperyio("GRID_Day").show();
}

else{
Apperyio("GRID_Day").hide();
}
/pre

GRID_Genre js:
pre
console.log("Genre = " + value.GenreInfoPage);
if(value.GenreInfoPage){
Apperyio("GRID_Genre").show();
}

else{
Apperyio("GRID_Genre").hide();
}

/pre
basically hiding the grid component if the value doesnt exist. and showing if the value does exist.

Image

mobilelabel_106 / ClubDescription_Label / GRID_VenueTel js:
pre
if (!value){
return false;
}
else {
return true;
}/pre

ClubWebsite_Label js:
pre
if (!value){
return "";
}

if (value){
return "Website";
}
/pre

Image

that is all the mapping to the page.
i also map 1 local storage variable as mentioned already

Image

I also 2 other services on the page ('rating' and 'CheckFavs4Night'). usually I have them invoked on 'Info_Rest' success. but in order to isolate what's causing the error I have these services run on click of test buttons on the page.

'rating' service doesnt cause the error to be seen.
but 'CheckFavs4Night' does cause the error to show.

CheckFavs4Night:

Image

LS session token is mapped to the session token header.
Js on where:
pre
return '{"$and": [{"Source_id":"' + value + '"},{"Nightlife_Type":"Night"}]}';/pre

Response:

Image

JS on notFaveGrid:
pre
if (!value) {
return true;
}

else return false;/pre

js on FavedGrid:
pre
if (!value) {
return false;
}

else return true;
/pre

so it appears that when 'Info_Rest' and 'CheckFavs4Night' are invoked the error is seen.
but neither of these are related to the map, also neither of these affect the map when they are invoked, so the end result for the user is the same. the services work fine and the map works fine.
My main concern is whether apple will reject the app because it continually receives this error when the page is shown.

Thanks for all of your efforts and time towards this problem. I hope my detailed response will help identify the cause.


How do I remove map markers?

Posted: Thu Jul 02, 2015 3:50 pm
by Serhii Kulibaba

We are sorry for delay.

You shoud init map variable before it's using. E.g.: http://stackoverflow.com/questions/28...