Polygons are made of Paths which are just MVCArrays (in this case, they're a list of LatLng objects). MVCArrays have three events: insert_at, remove_at, and set_at. We can use those events to detect changes in the points of the Polygon.

There are also drag events for polygons: dragstart, drag, and dragend. It's best to listen for dragend if you want to know that a shape was just dragged.

All together, we can detect any changes to a polygon:

// Loop through all paths in the polygon and add listeners
// to them. If we just used `getPath()` then we wouldn't
// detect all changes to shapes like donuts.
polygon.getPaths().forEach(function(path, index){ google.maps.event.addListener(path, 'insert_at', function(){
// New point
}); google.maps.event.addListener(path, 'remove_at', function(){
// Point was removed
}); google.maps.event.addListener(path, 'set_at', function(){
// Point was moved
}); }); google.maps.event.addListener(polygon, 'dragend', function(){
// Polygon was dragged
});
原文:http://stackoverflow.com/questions/20789385/how-can-i-detect-when-an-editable-polygon-is-modified

监听polygon变化的更多相关文章

  1. Angular.js中使用$watch监听模型变化

    $watch简单使用 $watch是一个scope函数,用于监听模型变化,当你的模型部分发生变化时它会通知你. $watch(watchExpression, listener, objectEqua ...

  2. $scope.$watch()——监听数据变化

    $scope.$watch(watchFn, watchAction, [deepWatch]):监听数据变化,三个参数 --watchFn:监听的对象,一个带有Angular 表达式或者函数的字符串 ...

  3. 如何使用NodeJs来监听文件变化

    1.前言 在我们调试修改代码的时候,每修改一次代码,哪怕只是很小的修改,我们都需要手动重新build文件,然后再运行代码,看修改的效果,这样的效率特别低,对于开发者来说简直不能忍. 2.构建自动编译工 ...

  4. android动态注册监听网络变化异常

    在使用广播接收器监听网络变化的时候,在AndroidManifest.xml中加入<user-permission android:name="android.permission.A ...

  5. Android实现后台长期监听时间变化

    1.首先我们的目的是长期监听时间变化,事实上应用程序退出. 通过了解我们知道注冊ACTION_TIME_TICK广播接收器能够监听系统事件改变,可是 查看SDK发现ACTION_TIME_TICK广播 ...

  6. Android 监听网络变化

    Android 监听网络变化

  7. --@angularJS--$scope.watch监听模型变化

    $watch简单使用 $watch是一个scope函数,用于监听模型变化,当你的模型部分发生变化时它会通知你. $watch(watchExpression, listener, objectEqua ...

  8. vue.js之过滤器,自定义指令,自定义键盘信息以及监听数据变化

    一.监听数据变化 1.监听数据变化有两种,深度和浅度,形式如下: vm.$watch(name,fnCb); //浅度 vm.$watch(name,fnCb,{deep:true}); //深度监视 ...

  9. webview缓存及跳转时截取url地址、监听页面变化

    缓存及一些设定 我在做一些项目时,h5做的项目手机浏览器能使用,但是在搬到webview时候不能用,这个时候通过查阅资料,原来是webview没有设定好,包括缓存.缓存大小及路径等等 mWebview ...

随机推荐

  1. OneAlert 入门(一)——事件流

    OneAlert 入门(一)--事件流 OneAlert 是国内首个 SaaS 模式的云告警平台,集成国内外主流监控/支撑系统,实现一个平台上集中处理所有 IT 事件,提升 IT 可靠性.它能以史上第 ...

  2. 窗体前端显示(ShowWindowAsync有许多优点)

    H:=FindWindow('Tfrm_MainForm','aa');  if H>0 then  begin    ShowWindowAsync(h,SW_MAX);    SetFore ...

  3. Tomcat7+Redis存储Session(转)

    PS:截止到2015-05-12前是不支持Tomcat8的,详情见官网:https://github.com/jcoleman/tomcat-redis-session-manager 前提:你已经部 ...

  4. bzoj2326

    首先不难得出递推式f[i]=(f[i-1]*10^k+i) mod m;f[i]表示接到第i个数时的余数,k表示i的位数不难想到先按位数穷举位数,然后对于确定的位数,构造矩阵解决易得出:f[i]   ...

  5. NOIP2014解方程

    题目:求一个n次整系数方程在1-m内的整数解  n<=100 系数<=10000位 m<=100W 题解:最暴力的想法是枚举x,带入求值看是否为0. 这样涉及到高精度乘高精度,高精度 ...

  6. Unity Kajiya Hair Shader Mod by Normals

    Shader "HairShader" { Properties { _MainTex ("Diffuse (RGB) Alpha (A)", 2D) = &q ...

  7. 对javabean的内省操作

    import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector ...

  8. 如何将下载好的jar包添加到maven本地仓库

    1.首先在pom.xml中添加 <dependency>    <groupId>org.springframework.security</groupId>    ...

  9. 【Android - 框架】之Dagger2+MVP的用法

    MVP模式本身相比于MVC模式就已经把View层和Controller层从Activity中进行了分离,将Model层和View层用Presenter层隔开,实现了初步的解耦.如果再加入Dagger2 ...

  10. MFC——error LNK2005: "protected: static struct AFX_MSGMAP

    好久没弄VC程序了,今天弄了下,还会用公司给的窗口重绘作为基类来实现,竟然报了这个错误. 找了一下是这里: 有个窗口重绘类是基类: class CBaseDlg : public CDialog 新建 ...