[solved]Google maps + infowindow


#1

I have 1 map, and need show events more info in this map, i create map, gerate events but, info not open my code is:

.controller('MapCtrl', function($scope) {       
		function error(transaction, err)
            {
                alert("DB error : " + err.message);
                return false;
            }
		
var markers=[];

		
		function setAllMap(map) {
  for (var i = 0; i < markers.length; i++) {
    markers[i].setMap(map);
  }
}
		
		
            function error(transaction, err)
            {
                alert("DB error : " + err.message);
                return false;
            }
           
                var mapOptions = {
                    zoom: 4,
                    center: new google.maps.LatLng(40.28052423420505, -7.504549920558929)
                };
				var map = new google.maps.Map(document.getElementById("map"), mapOptions);
				
										 var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
                db.transaction(function(transaction)
                {
					
                    var sql = 'SELECT * FROM DEMO';
                    transaction.executeSql(sql, undefined,
                            function(transaction, result)
                            {
                                var len = result.rows.length;
                                
                                var southWest = new google.maps.LatLng(40.28052423420505, -7.504549920558929);
                                var northEast = new google.maps.LatLng(40.29052423420505, -7.504549920558929);
                                var bounds = new google.maps.LatLngBounds(southWest, northEast);
                                map.fitBounds(bounds);

                                for (var i = 0; i < len; i++) {
                                    var position = new google.maps.LatLng(
                                            result.rows.item(i).LAT,
                                            result.rows.item(i).LON);
											
                                    var marker = new google.maps.Marker({
                                        position: position,
                                        map: map
                                    });
                                    marker.setTitle((i + 1).toString());
									var teste=result.rows.item(i).NEVENTO;
									var teste1=result.rows.item(i).DATA;
									var teste2=result.rows.item(i).DESC;
									var teste3=result.rows.item(i).LOCAL;
									var lat=result.rows.item(i).LAT;
									var lon=result.rows.item(i).LON;
									alert(teste);
                                    attachSecretMessage(marker, i, result.rows.item(i).NEVENTO);
		markers.push(marker);							
                                }
                                alert("Fim");
                            }, error);
                })
			

				 
				function attachSecretMessage(marker, num, message) {
                var infowindow = new google.maps.InfoWindow({
					
                    content: "Nome do evento:" + message
                });
				
               
			   
			    google.maps.event.addListener(marker, 'click', function() {
                    infowindow.open(marker.get('map'), marker);			
                });
            }
				

        $scope.map = map;
		
		$scope.main.dragContent = false;
})

tanks for help


#2

Can you put this into a codepen?


#3

We’re sorry, but because of the controllers could not add the code it, am new to this type of programming, and declare that it is not much need and after it :confused:
I believe the problem lies in the function:

google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(marker.get('map'), marker);			
            });

if withdraw

  google.maps.event.addListener(marker, 'click', function() {
                			
            });

works, that is, shows all the events with your description, but if updating the page so close you can reopen this info, it will be you could help me?


#4

tanks, problem soluve, i need this: scroll="false" data-tap-disabled="true" in <ion-content> in my page tab_map.html

tanks all for help