javascript - google map api multi markers -


i have make map company , have put company logo on 1 marker, , container icon on 10 others markers don' t know how it: current code : ( have first marker logo personal image can't see marker ) have make new variable "marker2" ? , make new variables each position of icons ?

var nice = new google.maps.latlng(43.7101728,7.2619532);  var centre = new google.maps.latlng(43.7101728,7.2619532);  var marker;  var map;    function initialize() {     var mapoptions = {      zoom: 14,      center: nice,                    };            map = new google.maps.map(document.getelementbyid('map-canvas'),            mapoptions);      marker = new google.maps.marker({      map:map,      draggable:false,      animation: google.maps.animation.drop,      position: centre,  	icon:'image/abi06b.png'    });                google.maps.event.addlistener(marker, 'click', togglebounce);  }    function togglebounce() {      if (marker.getanimation() != null) {      marker.setanimation(null);    } else {      marker.setanimation(google.maps.animation.bounce);    }  }    google.maps.event.adddomlistener(window, 'load', initialize);       
#map-canvas {          position: absolute;             height: 100%;         width:100%;  		  }
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>        <div id="map-canvas">      </div>

to answer question of
do have make new variable "marker2" ?
yes , no.

it seem might not 100% sure these code does:

  map = new google.maps.map(document.getelementbyid('map-canvas'),           mapoptions);    marker = new google.maps.marker({     map:map,     draggable:false,     animation: google.maps.animation.drop,     position: centre,     icon:'image/abi06b.png'   }); 

the map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); line, if creating google map in 'map-canvas' element, , function returns reference map object, can modify later.

then, marker = new google.maps.marker({ map:map,..... makes marker settings provided, include title, or icon image. function return reference, reference marker created, used future modification might need marker (changing icon, or deleting)

so.. need new google.maps.marker few (10) times, in loop. if don't need reference modifying markers later on, don't need make marker2, can use marker


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -