filipesala
Members-
Total de itens
2 -
Registro em
-
Última visita
Reputação
0 ComumSobre filipesala
-
Alterando cor do marcador ao clicar e desativando ao clicar em outro
filipesala postou um tópico no fórum Javascript
Bom dia gostaria de saber se algume pode me ajudar quando eu clico no marcador ele muda de cor porem quando clico em outro ele nao volta a cor original console.log('Yet another Hello world'); var map = null; var activeInfoWindow; placesOfInterest = [ { name: 'Charme da paulista', lat: -23.562172, lng: -46.655794 }, { name: 'The Blue Pub', lat: -23.563112, lng: -46.650338 }, { name: 'Veloso', lat: -23.585107, lng: -46.635219 }, { name: 'Let\'s Beer', lat: -23.586508, lng: -46.641739 }, { name: 'O\'Malley\'s', lat: -23.558296, lng: -46.665923 }, { name: 'Finnegan\'s', lat: -23.559547, lng: -46.676794 }, { name: 'Partisans', lat: -23.561049, lng: -46.682555 }, { name: 'Morrison', lat: -23.555106, lng: -46.690883 }, { name: 'Cão Véio', lat: -23.558130, lng: -46.679508 }, { name: 'Cervejaria Nacional', lat: -23.564740, lng: -46.690641 }, { name: 'Brewdog', lat: -23.561309, lng: -46.693935 }, { name: 'Rei das Batidas', lat: -23.570613, lng: -46.705977 } ]; const customIcon = { path: 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z', fillColor: 'white', fillOpacity: 0.98, scale: 0.98, strokeColor: '#666666', strokeWeight: 3 }; function addMarker(marker) { for (var i = 0; i < placesOfInterest.length; ++i) { var marker = new google.maps.Marker({ map: map, position: new google.maps.LatLng(marker.lat, marker.lng), icon: customIcon, title: marker.name }); attachSecretMessage(marker, placesOfInterest[i]); } function attachSecretMessage(marker) { var infowindow = new google.maps.InfoWindow({ content: marker.title, }); var cont = 0; google.maps.event.addDomListener(marker,'click', function() { if (activeInfoWindow) { activeInfoWindow.close(); } infowindow.open(map, marker); activeInfoWindow = infowindow; this.setIcon({ path: 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z', fillColor: 'black', fillOpacity: 0.98, scale: 0.98, strokeColor: '#666666', strokeWeight: 3 }) }); } } function initMap() { var mapOptions = { center: new google.maps.LatLng(-23.562172, -46.655794), gestureHandling: 'greedy', zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControlOptions: { mapTypeIds: [google.maps.MapTypeId.ROADMAP] }, disableDefaultUI: true, scaleControl: true, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.DEFAULT, } }; map = new google.maps.Map(document.getElementById('map'), mapOptions); //Adicionando o primeiro marcador como exemplo addMarker(placesOfInterest[1]); addMarker(placesOfInterest[0]); addMarker(placesOfInterest[2]); addMarker(placesOfInterest[3]); addMarker(placesOfInterest[4]); addMarker(placesOfInterest[5]); addMarker(placesOfInterest[6]); } -
Alterando cor do marcador ao clicar e desativando ao clicar em outro
filipesala postou um tópico no fórum Javascript
Bom dia gostaria de saber se algume pode me ajudar quando eu clico no marcador ele muda de cor porem quando clico em outro ele nao volta a cor original console.log('Yet another Hello world'); var map = null; var activeInfoWindow; placesOfInterest = [ { name: 'Charme da paulista', lat: -23.562172, lng: -46.655794 }, { name: 'The Blue Pub', lat: -23.563112, lng: -46.650338 }, { name: 'Veloso', lat: -23.585107, lng: -46.635219 }, { name: 'Let\'s Beer', lat: -23.586508, lng: -46.641739 }, { name: 'O\'Malley\'s', lat: -23.558296, lng: -46.665923 }, { name: 'Finnegan\'s', lat: -23.559547, lng: -46.676794 }, { name: 'Partisans', lat: -23.561049, lng: -46.682555 }, { name: 'Morrison', lat: -23.555106, lng: -46.690883 }, { name: 'Cão Véio', lat: -23.558130, lng: -46.679508 }, { name: 'Cervejaria Nacional', lat: -23.564740, lng: -46.690641 }, { name: 'Brewdog', lat: -23.561309, lng: -46.693935 }, { name: 'Rei das Batidas', lat: -23.570613, lng: -46.705977 } ]; const customIcon = { path: 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z', fillColor: 'white', fillOpacity: 0.98, scale: 0.98, strokeColor: '#666666', strokeWeight: 3 }; function addMarker(marker) { for (var i = 0; i < placesOfInterest.length; ++i) { var marker = new google.maps.Marker({ map: map, position: new google.maps.LatLng(marker.lat, marker.lng), icon: customIcon, title: marker.name }); attachSecretMessage(marker, placesOfInterest[i]); } function attachSecretMessage(marker) { var infowindow = new google.maps.InfoWindow({ content: marker.title, }); var cont = 0; google.maps.event.addDomListener(marker,'click', function() { if (activeInfoWindow) { activeInfoWindow.close(); } infowindow.open(map, marker); activeInfoWindow = infowindow; }); } } function initMap() { var mapOptions = { center: new google.maps.LatLng(-23.562172, -46.655794), gestureHandling: 'greedy', zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControlOptions: { mapTypeIds: [google.maps.MapTypeId.ROADMAP] }, disableDefaultUI: true, scaleControl: true, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.DEFAULT, } }; map = new google.maps.Map(document.getElementById('map'), mapOptions); //Adicionando o primeiro marcador como exemplo addMarker(placesOfInterest[1]); addMarker(placesOfInterest[0]); addMarker(placesOfInterest[2]); addMarker(placesOfInterest[3]); addMarker(placesOfInterest[4]); addMarker(placesOfInterest[5]); addMarker(placesOfInterest[6]); }