Google地图中多边形的工具提示 [英] Tooltip over a Polygon in Google Maps

查看:131
本文介绍了Google地图中多边形的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有多个区域和州的多边形。标记通过获取title属性来实现工具提示。在多边形上的mouseover和mouseout可以被触发。如何创建一个看起来像是为标记实现的工具提示的工具提示。

I have polygons for various region and states in my application. Markers implement tooltip by taking the title attribute. On mouseover and mouseout over a polygon events can be fired. How do I create a tooltip that looks like the tooltip that is implemented for a marker.

编辑-1:添加用于创建多边形的代码并将处理程序附加到显示/隐藏工具提示。
$ b

Edit-1: Adding the code used to create the polygon and attach the handlers to show/hide tooltips.

function addPolygon(points) {
    var polygon = new google.maps.Polygon({
        paths: points,
        strokeColor: " #FFFFFF",
        strokeOpacity: 0.15,
        strokeWeight: 1.5,
        fillColor: "#99ff66",
        fillOpacity: 0.14
    });
    var tooltip = document.createElement('div');
    tooltip.innerHTML = "Alok";

    google.maps.event.addListener(polygon,'mouseover',function(){
        tooltip.style.visibility = 'visible';
    });
    google.maps.event.addListener(polygon,'mouseout',function(){
        tooltip.style.visibility = 'hidden';
    });
    polygon.setMap(map);
}


推荐答案

我认为您必须自己动手。在我实现的页面中,我在页面上附加了一个鼠标移动事件,这样我就可以记录鼠标位置。然后,当发生多边形mouseover事件时,我会在鼠标位置附近显示一个自定义div

I think you will have to do it yourself.In a page i have implemented i attached a mouse move event to the page so i can record the mouse position.Then when a polygon mouseover event occurs i display a custom div near the mouse position

希望它有帮助

这篇关于Google地图中多边形的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆