2017-10-27 2 views
0

Google지도 라이브러리를 사용하여 Google지도에 여러 마커를 추가했습니다. 제대로 작동하지만 내 문제는 마커의 이름을 onmouseover로 표시하고 싶습니다. 그리고 나는 이것 같이 시도했다.마커에 이름 onmouseover를 표시하는 방법 : Google지도 API

코드 :

$config['zoom'] = 'auto'; 
    $this->googlemaps->initialize($config); 
    $i = 0; 
    while($i < $rs){ 
    $marker = array(); 
    $marker['position'] = $data['tunnelsname'][$i]->name; 
    $marker['onmouseover'] = 'hii'; 
    $x = $data['tunnelsname'][$i]->name; 
    $name = strtolower(str_replace(' ','-',$data['tunnelsname'][$i]->name)); 
    $id = $data['tunnelsname'][$i]->id; 
    $marker['infowindow_content'] = '<a href = "'.BASEURL.'tunnel/'.$name.'/'.$id.'">'.$x.'</a>'; 
    $marker['clickable'] = TRUE; 
    $this->googlemaps->add_marker($marker); 
    $i++; 
    } 
    $data['map'] = $this->googlemaps->create_map(); 

내가 원하는 result.Please이 얻을하는 데 도움이 얻을 수 없습니다 각 marker.But에 onMouseover와 HII를 표시하려합니다.

도움이 될 것입니다. 미리 감사드립니다.

답변

3

"mouseover"와 같은 사용자 상호 작용은 클라이언트 측 구현을 사용하여 구현하는 것이 훨씬 쉽다고 생각합니다. 확인 When to use client-side geocodingWhen to use server-side geocoding.

샘플 코드 자세한 정보를 원하시면

marker.addListener('mouseover', function() { 
    infoWindow.setContent('<p>hii</p>'); 
    infowindow.open(map, this); 
}); 

// assuming you also want to hide the infowindow when user mouses-out 
marker.addListener('mouseout', function() { 
    infowindow.close(); 
}); 

확인 Maps JavaScript API Events.

0

onmouseover에 짧은 텍스트를 표시하는 쉽고, 이미 구현 된 방법은 마커 "title"속성을 사용하는 것입니다. 당신은 기본 마커 정의에 직접 사용할 수 있습니다

var marker = new google.maps.Marker({ 
    position: {lat: x.x, lng: x.x}, 
     title: 'hii', 
    map: map 
}); 

또는 나중에 재산 사용하여 수행

marker.setTitle('hii')