php - Problems with Multiple Google Maps on One Page -
hi have problems display more 1 google maps on 1 page
the first map shows correctly second doesnt show
i use smarty display templates. results comes db. can check code , me display more 1 map
{foreach item=row from=$adress} <tr> <td> <script type="text/javascript"> function initialize() { var position = new google.maps.latlng({$row->lat}, {$row->longi}); var myoptions = { zoom: 12, center: position, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map( document.getelementbyid("map_canvas{$row->site_id}"), myoptions); var marker = new google.maps.marker({ position: position, map: map, title:"this place." }); var contentstring = 'hello <strong>world</strong>!'; var infowindow = new google.maps.infowindow({ content: contentstring }); google.maps.event.addlistener(marker, 'click', function() { infowindow.open(map,marker); }); } </script> <div id="map_canvas{$row->site_id}" style="width:300px;height:200px;"></div>
here html code:-
</head> <body onload="initialize()"> <h1 align="center">two google maps side-by-side</h1> <div id="map_canvas1" style="top: 10px; left: 25px; width:210px; height:220px; float: left"></div> <div id="map_canvas2" style="top: 10px; left: 75px; width:210px; height:220px"></div> </body> </html> <script> function initialize() { <?php for($i=1; $i<=2; $i++){ ?> var latlng<?php echo $i ?> = new google.maps.latlng(18.520266,73.856406); var myoptions = { zoom: 15, center: latlng<?php echo $i; ?>, maptypeid: google.maps.maptypeid.roadmap }; var map<?php echo $i; ?> = new google.maps.map(document.getelementbyid("map_canvas<?php echo $i ?>"), myoptions); var mymarker<?php echo $i; ?> = new google.maps.marker( { position: latlng<?php echo $i; ?>, map: map<?php echo $i; ?>, title:"pune" }); <?php } ?> } </script>
i know using different programming language define code. logic hope understood.
Comments
Post a Comment