监听polygon变化
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变化的更多相关文章
- Angular.js中使用$watch监听模型变化
$watch简单使用 $watch是一个scope函数,用于监听模型变化,当你的模型部分发生变化时它会通知你. $watch(watchExpression, listener, objectEqua ...
- $scope.$watch()——监听数据变化
$scope.$watch(watchFn, watchAction, [deepWatch]):监听数据变化,三个参数 --watchFn:监听的对象,一个带有Angular 表达式或者函数的字符串 ...
- 如何使用NodeJs来监听文件变化
1.前言 在我们调试修改代码的时候,每修改一次代码,哪怕只是很小的修改,我们都需要手动重新build文件,然后再运行代码,看修改的效果,这样的效率特别低,对于开发者来说简直不能忍. 2.构建自动编译工 ...
- android动态注册监听网络变化异常
在使用广播接收器监听网络变化的时候,在AndroidManifest.xml中加入<user-permission android:name="android.permission.A ...
- Android实现后台长期监听时间变化
1.首先我们的目的是长期监听时间变化,事实上应用程序退出. 通过了解我们知道注冊ACTION_TIME_TICK广播接收器能够监听系统事件改变,可是 查看SDK发现ACTION_TIME_TICK广播 ...
- Android 监听网络变化
Android 监听网络变化
- --@angularJS--$scope.watch监听模型变化
$watch简单使用 $watch是一个scope函数,用于监听模型变化,当你的模型部分发生变化时它会通知你. $watch(watchExpression, listener, objectEqua ...
- vue.js之过滤器,自定义指令,自定义键盘信息以及监听数据变化
一.监听数据变化 1.监听数据变化有两种,深度和浅度,形式如下: vm.$watch(name,fnCb); //浅度 vm.$watch(name,fnCb,{deep:true}); //深度监视 ...
- webview缓存及跳转时截取url地址、监听页面变化
缓存及一些设定 我在做一些项目时,h5做的项目手机浏览器能使用,但是在搬到webview时候不能用,这个时候通过查阅资料,原来是webview没有设定好,包括缓存.缓存大小及路径等等 mWebview ...
随机推荐
- 【POJ2417】baby step giant step
最近在学习数论,然而发现之前学的baby step giant step又忘了,于是去翻了翻以前的代码,又复习了一下. 觉得总是忘记是因为没有彻底理解啊. 注意baby step giant step ...
- 关于__irq 的使用
__irq为一个标识,用来表示一个函数是否为中断函数. 对于不同的编译器,__irq在函数名中的位置不一样,例如: ADS编译器中 : void __irq IRQ_Eint0(void); Keil ...
- Java System类看到的一点小记
System类 位置java.lang包中 是final类,不能被继承,不能被修改 ,不能被实例化 private System(){}私有的构造函数,不允许被其他对象进行实例化 public fin ...
- android.graphics.Matrix
Matrix类包含了一个3x3的矩阵用来改变坐标,它没有一个构造器来初始化它里边的内容,所以创建实例后需要调用reset()方法生成一个标准matrix,或者调用set..一类的函数,比如setTra ...
- .net framework client profile
.NET Framework Client Profile The .NET Client Profile is a subset of the .NET Framework, which was p ...
- C++ Prime:预处理器
C++程序会用到的一项预处理功能是头文件保护符,头文件保护符依赖于预处理变量.预处理变量有两种状态:已定义和未定义,#define指令把一个名字设定为预处理变量,另外两个指令则分别检查某个指定的预处理 ...
- 字符串(后缀自动机):Ahoi2013 差异
Description Input 一行,一个字符串S Output 一行,一个整数,表示所求值 Sample Input cacao Sample Output 54 HINT 2<=N< ...
- Java---网络编程(4)-C/S-B/S
C/S 与 B/S ☆ C/S ( Client/Server ) 客户端和服务端的特点 1.客户端和服务端的软件都需要程序员进行编写. 2.客户端维护起来较为麻烦.(缺陷) 3.客户端的存在可以将一 ...
- MVC项目初次发布到IIS可能会遇到的问题
MVC4 + .NET Framework 4.5 +Windows Server 2008+ IIS7.5 + 4.0集成模式池 ,初次发布后可能会遇到404.0 或者403.14错误,加入以下代码 ...
- OPC客户端的进程安全初始化
现场OPC客户端无法获取远程OPC Server列表,也无法连接OPC Server,经查调用CoCreateInstanceEx()创建IID_IOPCServerList接口正常,但调用IOPCS ...