javascript - Marker Visibility Google Maps API -


i have created 3 markers using google maps api, want 1 marker active @ time because each marker represents scoring sequence in game. example, if score 0 want chicago marker active. lost on how great. here of code:

<script>       var map;       var score;       function initmap() {         var chicago = {lat: 41.8781, lng: -87.6298};         var indianapolis = {lat: 39.7684, lng: -86.1581};         var oklahomacity = {lat: 35.4819, lng: -97.5084};          map = new google.maps.map(document.getelementbyid('map'), {           center: {lat: 0.0, lng: 0.0},           zoom: 1 });         var chicagomarker = new google.maps.marker({             position: chicago,             map: map          });          var oklahomacitymarker = new google.maps.marker({             position: oklahomacity,             map:map });          var indianapolismarker = new google.maps.marker({             position: indianapolis,             map:map  });   chicagomarker.setvisible(false); indianapolismarker.setvisible(false); oklahomacitymarker.setvisible(false);     }     </script>     <script src="https://maps.googleapis.com/maps/api/js?key=aizasycuvscaf0gvmwv6af0soa3xbjv66rg4r7o&callback=initmap"     async defer></script> 

create marker withoou map attribute , assugn setmap(map) if socre 0 var map;

    var score;     function initmap() {       var chicago = {lat: 41.8781, lng: -87.6298};       var indianapolis = {lat: 39.7684, lng: -86.1581};       var oklahomacity = {lat: 35.4819, lng: -97.5084};        map = new google.maps.map(document.getelementbyid('map'), {         center: {lat: 0.0, lng: 0.0},         zoom: 1       });       var chicagomarker = new google.maps.marker({           position: chicago       });        var oklahomacitymarker = new google.maps.marker({           position: oklahomacity       });        var indianapolismarker = new google.maps.marker({           position: indianapolis       });        if ( score == 0) {         chicagomarker.setmap(map)       }    } </script> 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -