我使用角谷歌地图和需要帮助获得新的变化范围从事件发射 [英] I'm using angular google maps and need help getting the new bounds changed from the event fired

查看:178
本文介绍了我使用角谷歌地图和需要帮助获得新的变化范围从事件发射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我目前的code时的界限,改变了被称为和作品:

This is my current code which is called when bounds are changed and works:

 scope.boundsChanged= function(arg){
       console.log(arg);                       
 };

基本上,我需要lat和液化天然气的新阵列时上面这个函数被调用。
我不确定是检索。

I basically need the new array of lat and lng when this function above is called. I'm unsure are the retrieve it.

我在一家指令采用了棱角分明的版本1使用JavaScript使用templateUrl。

I'm using angular version 1 with JavaScript in a directive using a templateUrl.

界控制台日志图精氨酸:

在这里输入的形象描述

推荐答案

我不知道究竟是什么在boundsChanged()函数返回,但假设改变的界限,在函数返回的,方法是相同的获得纬度,经度坐标:

I dont know exactly what is returned in the boundsChanged() function, but assuming changed bounds are returned in the function, method is the same to get lat, lng coordinates:

scope.boundsChanged= function(arg){

    //assuming changed bounds is returned as the 'arg'
    var polygonBounds = arg;
    var coordinates = [];

    for (var i = 0; i < polygonBounds.length; i++)
    {
        coordinates.push({lat: polygonBounds.getAt(i).lat(), lng: polygonBounds.getAt(i).lng()});
        coordinates.push(new google.maps.LatLng(polygonBounds.getAt(i).lat(), polygonBounds.getAt(i).lng()));
    }

   console.log(arg);                       
};

这篇关于我使用角谷歌地图和需要帮助获得新的变化范围从事件发射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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