Custom Google Maps Markers and Infowindow -
i want create google map in markers want show coming database , infowindow data comes database different each marker obviously. code using is:
<script type="text/javascript"> var delay = 100; var infowindow = new google.maps.infowindow(); var latlng = new google.maps.latlng(21.0000, 78.0000); var mapoptions = { zoom: 5, center: latlng, maptypeid: google.maps.maptypeid.roadmap } var geocoder = new google.maps.geocoder(); var map = new google.maps.map(document.getelementbyid("map_canvas"), mapoptions); var bounds = new google.maps.latlngbounds(); function geocodeaddress(address, next) { geocoder.geocode({address:address}, function (results,status){ if (status == google.maps.geocoderstatus.ok) { var p = results[0].geometry.location; var lat=p.lat(); var lng=p.lng(); createmarker(address,lat,lng); }else { if (status == google.maps.geocoderstatus.over_query_limit) { nextaddress--; delay++; } else {} } next(); }); } function createmarker(add,lat,lng) { var contentstring = add; var marker = new google.maps.marker({ position: new google.maps.latlng(lat,lng), map: map }); google.maps.event.addlistener(marker, 'click', function() { infowindow.setcontent(contentstring); infowindow.open(map,marker); }); bounds.extend(marker.position); } <?php global $wpdb; $results = $wpdb->get_results("select * $wpdb->postmeta meta_value = 'canada'"); $num_rows = $wpdb->num_rows; ?> var locations = [ <?php foreach ($results $doc_meta_data) { echo "'";// . $doc_meta_data->meta_id; echo get_post_meta($doc_meta_data->post_id, 'address', true).","; echo get_post_meta($doc_meta_data->post_id, 'state', true).","; echo get_post_meta($doc_meta_data->post_id, 'country', true); echo "',"; }?> ]; var nextaddress = 0; function thenext() { if (nextaddress < locations.length) { settimeout('geocodeaddress("'+locations[nextaddress]+'",thenext)', delay); nextaddress++; } else { map.fitbounds(bounds); } } thenext(); </script>
how can add make each markers info dynamic ie, should come admin panel. url:http://intigateqatar.com/ozone/find-a-doc/
you need create infowindow in createmarker()
function in order infowindows unique each marker:
function createmarker(add,lat,lng) { var contentstring = add; var marker = new google.maps.marker({ position: new google.maps.latlng(lat,lng), map: map }); var infowindow = new google.maps.infowindow({ content: contentstring }); google.maps.event.addlistener(marker, 'click', function() { infowindow.open(map, marker); }); bounds.extend(marker.position); }
Comments
Post a Comment