json - i have some marker, every marker with it's info. window , how can i customize them in one info window on javascript -
i have marker, every marker it's info. window , how can customize them in 1 info window, , every time re-assign data when click on different one? on javascript
self.getcontent = '<div class="window-content" style="background-color:#a0785c;padding:5px;color:#fff;text-transform:uppercase; border-radius:5px;"><div class="title"><h4 style="color:#38c3ea;">' + self.title + "</h4></div>" + '<div class="extrcontent"> ( ' + self.lat + ' , ' + self.lng + " ) </div>" + '<div class="extrcontent"> city ->' + " " + self.city + "</div>" + '<div class="extrcontent"> street ->' + " " + self.street + "</div>" + '<div class="extrcontent">' + self.checkinscount + " checkins </div></div>"; }); self.getcontent = '<div class="window-content" style="background-color:#a0785c;padding:5px;color:#fff;text-transform:uppercase; border-radius:5px;"><div class="title"><h4>' + self.title + "</h4></div>" + '<div class="extrcontent">' + self.city + "</div>" + '<div class="extrcontent">' + self.street + "</div>" + '<div class="extrcontent">' + self.checkinscount + "</div></div>"; // define infowindow self.infowindow = new google.maps.infowindow({ content: self.getcontent }); // add , show markers self.marker = new google.maps.marker({ position: new google.maps.latlng(data.location.lat, data.location.lng), map: map, title: data.title, animation: google.maps.animation.drop, }); // function show markers on map this.isvisible = ko.observable(false); this.isvisible.subscribe(function(currentstate) { if (currentstate) { self.marker.setmap(map); } else { self.marker.setmap(null); } }); this.isvisible(true); // contect infowindows self.marker.addlistener('click', function() { // declare info window self.infowindow = new google.maps.infowindow({ content: self.getcontent }); self.infowindow.setcontent(self.getcontent); self.infowindow.open(map, this); // set marker animation self.marker.setanimation(google.maps.animation.drop); }); };
Comments
Post a Comment