En este momento puedo clickear en cualquier parte del mapa, la idea es que se pueda clickear solamente donde esta el polígono. Gracias!
Controller:
$scope.map = {
events: {
click: function (mapModel, eventName, originalEventArgs) {
console.log("user defined event: " + eventName, mapModel, originalEventArgs);
var e = originalEventArgs[0];
$scope.$apply();
$scope.latitud = e.latLng.lat();
$scope.longitud = e.latLng.lng();
}
}
};
$scope.polygons = [
{
id: 1,
clickable: false,
path: [
{
latitude: -34.611345,
longitude: -55.450871
},
{
latitude: -34.594056,
longitude: -55.349145
},
{
latitude: -34.555720,
longitude: -55.327829
},
{
latitude: -34.475802,
longitude: -55.181059
},
{
latitude: -34.357981,
longitude: -54.867948
},
{
latitude: -34.038130,
longitude:
-54.725110
},
{
latitude: -34.013307,
longitude: -54.594584
},
//norte
{
latitude: -33.890545,
longitude: -54.510057
},
//
{
latitude: -34.008967,
longitude: -54.466028
},
{
latitude: -34.803462,
longitude: -54.532865
},
{
latitude: -34.852526,
longitude: -54.630319
},
//sur
{
latitude: -34.977426,
longitude: -54.953992
},
{
latitude: -34.918299,
longitude: -55.048001
},
//
{
latitude: -34.907468,
longitude: -55.263573
},
{
latitude: -34.798692,
longitude: -55.393695
},
{
latitude: -34.726899,
longitude: -55.457069
},
{
latitude: -34.617944,
longitude: -55.488490
},
{
latitude: -34.596882,
longitude: -55.465612
},
{
latitude: -34.611345,
longitude: -55.450871
},
],
stroke: {
color: '#6060FB',
weight: 1
},
editable: true,
draggable: false,
geodesic: false,
visible: true,
fill: {
color: '#dbf7c8',
opacity: 0.1
}
}
];
HTML:
<ui-gmap-google-map center='map.center' zoom='map.zoom' events='map.events'>
<ui-gmap-polygon static="true" clickable="p.clickable" ng-repeat="p in polygons track by p.id" path="p.path" stroke="p.stroke" visible="p.visible"
geodesic="p.geodesic" fill="p.fill" fit="false" editable="p.editable" draggable="p.draggable"></ui-gmap-polygon>
</ui-gmap-google-map>