I currently have a location search kind of web app where user can look find places they interest of, now i had integrate search result with google maps. This works fine as result display the maps will have marker. But some marker are out of range which user need to zoom out before they can view it, how can i use jquery so that if user mouse over list a
tag the map will autopan to find the related marker? Folowing are my code:
<div class="businessresult clearfix" uid="5">
<h4 class="itemheading" id="bizTitle0">
<a id="bizTitleLink0" href="/business/hotel5">1.Hotel5</a>
</h4>
</div>
<div class="businessresult clearfix" uid="4">
<h4 class="itemheading" id="bizTitle0">
<a id="bizTitleLink0" href="/business/hotel4">2.Hotel4 </a>
</h4>
</div>
<div class="businessresult clearfix" uid="3">
<h4 class="itemheading" id="bizTitle0" >
<a id="bizTitleLink0" href="/business/hotel3">3.Hotel3 </a>
</h4>
</div>
Google maps js:
<script type="text/javascript">
var gmap, gpoints = [];
var flat = '<?=$this->biz[0]["y"]?>';
var flng = '<?=$this->biz[0]["x"]?>';
$(document).ready(function() {
initialize();
});
function initialize() {
gmap = new google.maps.Map(document.getElementById('map-container'), {
zoom: 13,
streetViewControl: false,
scaleControl: false,
center: new google.maps.LatLng(flat, flng),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
<?php
foreach ($this->paginator as $bizArr) {
$lat = $bizArr['y'];
$long = $bizArr['x'];
$name = addslashes($bizArr['business_name']);
$rating = $bizArr['rating'];
$content = '';
?>
gpoints.push( new point(gmap, '<?=$lat; ?>', '<?=$long; ?>', '<?php echo $content; ?>',gmap.center) );
<?php } ?>
}
function point(_map, lat, lng, content,center) {
this.marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,lng),
map: _map,
tooltip: content
});
var gpoint = this;
var tooltip = new Tooltip({map: _map}, gpoint.marker);
tooltip.bindTo("text", gpoint.marker, "tooltip");
google.maps.event.addListener(gpoint.marker, 'mouseover', function() {
tooltip.addTip();
tooltip.getPos2(gpoint.marker.getPosition());
//_map.panTo(gpoint.marker.getPosition())
});
google.maps.event.addListener(gpoint.marker, 'mouseout', function() {
tooltip.removeTip();
});
google.maps.event.addListener(gpoint.marker, 'click', function() {
_map.setZoom(15);
_map.setCenter(gpoint.marker.getPosition());
});
}
</script>
Thanks