mpriour / azimuthjs

A geo webapp building companion to AngularJS
52 stars 19 forks source link

How to add OL's Panel and DrawControl to Map ? #4

Open gowram opened 11 years ago

gowram commented 11 years ago

Hi Matt,

I would like to add Panel and Draw Controls for vector layer, I am currently working on functionality for User would be able to draw features and add properties which eventually converted to GeoJSON format.

Is it possible and how to achieve ?

Thanks Rama

mpriour commented 10 years ago

You can add any control and specify its options it in the map directive markup. see:

To add a geolocation control:

<div ol-map controls="zoom,navigation,attribution,geolocate" control-opts="{geolocate:{geolocationOptions:{enableHighAccuracy: true, maximumAge: 30000}}">
</div>

Alternatively, you could get a reference to the map object and from there you can add on whatever you like to the map directly.

I don't currently have any examples showing how to get the map object reference, but you would do it by creating a simple controller and it would share the same variable name in the controller scope as the olmap directive in the markup.

ex:

<div ng-controller="MyController">
  <div ol-map="mymap">
        <az-layer name="Street" lyr-type="tiles"></az-layer>
  </div>
</div>
function MyController(){
  this.mymap = null
}

MyController.prototype.doSomething = function(){
  this.mymap.setCenter([-97,35], 10);
}
gowram commented 10 years ago

Thanks.