Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle maps with multiple markers from a php array
    primarykey
    data
    text
    <p>Hi have an array of cities and want to create a google map using the javascript api v3 . When the page loads the map keeps jumping to each marker. Also the the map becomes very small even though i have set a height and width to it .Here is my code for generating the map</p> <pre><code>&lt;script&gt; var geocoder; var map; var timeout = 600; var address_position = 0; var address = [ &lt;?php foreach($cities_in_country as $item) { echo '"'.$item['name'].'",'; } ?&gt; ]; function addMarker(position) { geocoder.geocode({'address': address[position]}, function(results, status) { address_position++; if (address_position &lt; address.length) { setTimeout(function() { addMarker(address_position); }, (timeout)); } if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) { setTimeout(function() { addMarker(position); }, (timeout * 3)); } else if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ position: results[0].geometry.location, map: map, icon:"&lt;?=base_url()?&gt;assets/goo/images/icons/marker.png", }); } }); } function codeaddress() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 6, center: latlng, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, mapTypeId: google.maps.MapTypeId.ROADMAP, } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); addMarker(address_position); } $(document).ready(function() { codeaddress(); }); &lt;/script&gt; </code></pre> <p>and</p> <pre><code>&lt;div id="map_canvas" style="width: 640px; height: 420px;"&gt;&lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload