Exemplo n.º 1
0
int mapObj_insertLayer(mapObj *self, layerObj *layer, int index)
{
    if (self && layer)
      return msInsertLayer(self, layer, index);

    return -1;
}
Exemplo n.º 2
0
Handle<Value> MSMap::InsertLayer (const Arguments& args) {
  HandleScope scope;
  MSMap *map = ObjectWrap::Unwrap<MSMap>(args.This());
  MSLayer *layer;
  Local<Object> obj;
  int result;
  int position = -1;

  if (args.Length() < 1) {
    THROW_ERROR(Error, "insertLayer requires at least one argument");
  }

  if (!args[0]->IsObject()) {
    THROW_ERROR(TypeError, "first argument to project must be Layer object");
  }

  obj = args[0]->ToObject();

  if (obj->IsNull() || obj->IsUndefined() || !MSLayer::constructor->HasInstance(obj)) {
    THROW_ERROR(TypeError, "first argument to project must be Layer object");
  }

  layer = ObjectWrap::Unwrap<MSLayer>(obj);

  if (args.Length() == 2) {
    if (!args[1]->IsNumber()) {
      THROW_ERROR(TypeError, "second argument must be an integer");
    } else {
      position = args[1]->ToInteger()->Value();
      if (position >= map->this_->numlayers) {
        position = -1;
      }
    }
  }
  result = msInsertLayer(map->this_, layer->this_, position);

  return scope.Close(Number::New(result));
}